[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 317
Thread images: 38

File: 1483394413278.jpg (72KB, 440x406px) Image search: [Google]
1483394413278.jpg
72KB, 440x406px
What are you working on, /g/?
Old thread: >>58320789
>>
First for C
>>
FunctIonal programming thread:
>>58301640
>>
File: 1483559814715.gif (662KB, 292x300px) Image search: [Google]
1483559814715.gif
662KB, 292x300px
THANK YOU for using an anime image
You have no idea how grateful I am
>>
>>58325707
About as functional as your spelling
>>
>>58325698
You can fill out a value for the record normally, if that's what you're asking.

Having two separate lambdas with two separate environments isn't what I want here. It's suboptimal and doesn't play nicely with e.g. linear types.
>>
File: CryingWojak.jpg (55KB, 500x500px) Image search: [Google]
CryingWojak.jpg
55KB, 500x500px
>>58325678
I was about to create a new thread.
I want the (You)s.
>>
Text editor poll continues
http://www.strawpoll.me/12023125
>>
>>58325678
I just finished a caesar cipher program in ruby that I got from a a roll thread and it was way harder than it should have been. Mostly because I was going off the learnxinyminutes ruby tutorial to try and refresh myself, so my syntax was off, but also i forgot a bunch of basic shit and I am realizing how much I've lost in a 2 year break.
>>
>>58325730
Don't you know lad? The gook tookaway all of our precious (you)s.
>>
>>58325733
Vim, Emacs and Nano are the only acceptable answers.
>>
>>58325733
>http://www.strawpoll.me/12023125
I chose other. I used to use vim, but now I just use pluma because it is default in ubuntu mate and has syntax highlighting, which is all I care about.
>>
>>58325678
quality thread
thanks, OP
>>58325752
No, (You)s are back
>>58325730
here, have one
>>
>Intel CPUs can do AES
Holy moly
>>
File: for(You).png (11KB, 476x87px) Image search: [Google]
for(You).png
11KB, 476x87px
>>58325752
>>
Ok guys, I need some help. I need to make my program faster, but I just cant figure out how. Here is the problem, I have some numbers sorted like this:
| 7
| 4 8
| 2 5 9
| 1 3 6 10

I have to output a number depending on the input. The input is going to be two integers, think of them as x and y coordinates. The x is how many away from the left I go and the y is how many from the bottom I go. So say x and y are 1 and 1, then I would have to output 5. Now my code works and gets the correct number, but it is too damn slow.
def answer(x, y):
last_num = 1
arr_hold = [[1]]
for i in range(2, x+(y+2)):
reg_hold = []
for j in range(last_num + 1, i + last_num + 1):
if j == (i + last_num + 1) - 1:
last_num = j
if i == (x+(y+2)) - 1:
reg_hold.append(j)
print(reg_hold)
return reg_hold[x]

Is there anything I can do to speed it up?
>>
>>58325805
Forgot to mention, I have to use python.
>>
File: 1449015339592.jpg (4KB, 225x224px) Image search: [Google]
1449015339592.jpg
4KB, 225x224px
>>58325733
>no pico
what a fucking joke
>>
>>58325797
AES is just bitwise operations and vector transforms.
>>
>>58325814
>>58325805
this is definitely homework
do it yourself
>>
anyone here on adderall? does it help? I have trouble sticking to a programming book so I haven't really learned anything yet
>>
>>58325817
How is it different from nano?
>>
>>58325817
the '90s ended 17 years ago
>>
>>58325679
>>58325679
>>58325679
6
5
4
3
2
1
c++


this was actually teh language i was hoping would win.
>>
>>58325838
I can promise you it isn't homework. But I do want to solve it.
>>
>>58325845
2050 was 30 years ago
>>
>>58325817
>implying functional difference from nano
Go be a hipster somewhere else :^)
>>
>>58325714
dumb karen poster
>>
>>58325860
>2015 will be 33 years from now
holy fuck that's not better
I will be a fucking old man in 2050
>>
>C# and Java slower than V8 and LuaJIT
>>
>>58325874
Please don't bully karen
>>
>>58325838
Obvious newfag, We only shoot someone down if they don't try.
>>58325805
I am pretty sure there is an algorithm for this, can't remember the name though.
>>
>>58325851
> Not including Ada to the choices
It's like you don't want to be challenged
>>
>>58325883
And you will still be a virgin.
>>
>>58325883
>2015
lel
2050*
>>
File: jealous.jpg (140KB, 848x480px) Image search: [Google]
jealous.jpg
140KB, 848x480px
>>58325874
>>
>>58325907
y u heff 2 be mean liek dis
>>
>>58325883
>implying the year isn't an 11-bit value
>implying you won't be an old man in year 2
>>
>>58325805
def answer(x, y):
last_num, arr_hold = 1,[[1]]
for i in xrange(2, x+(y+2)):
reg_hold = []
for j in xrange(last_num + 1, i + last_num + 1):
if j == (i + last_num):
last_num = j
if i == (x+(y+1)):
reg_hold.append(j)
print(reg_hold)
return reg_hold[x]
>>
>>58325886
pajeets on suicide watch
>>
>>58325960
definitely a little faster, but no where near fast enough. The highest number x or y can be is 100000
>>
>>58326019
the thing is with 2 loops with the range of 100000, will always be slow

so you have to use dynamic programming or some sort of memoization

also, arr_hold is defined but never used
>>
>>58326114
Oops, forgot about arr_hold, I have went through about 10 different ways of doing this over the last couple of hours and this is the fastest I could come up with.
>>
>>58325960
Can't you write everything to a matrix and access by index?
>>
Here's a challenge! >:D
Write a program which, given a string representation of an integer, determines the minimum amount of bits required to represent it.
>>
>>58326199
yes
>>
>>58326225
seems you are challenged already
>minimum amount of bits required to represent it
I don't know what to say anymore
>>
>>58326228
Wouldn't it be faster?
>>
>>58326225
def lmao(value):
value,count = int(value),0
while (value > 0):
count+=1
value>>=1
return count
>>
>>58326295
but that's what he's doing, i'm afraid
>>
>>58326285
Sorry I forgot to say no snarky nihilists please :O
By all means go back to doing nothing with every day of your life ;-)
>>
>>58326329
I'm afraid not.
memetrix = [[1],[2,3],[4,5,6]]
print memetrix[y][x]
>>
File: written_in.png (26KB, 285x283px) Image search: [Google]
written_in.png
26KB, 285x283px
I'm actually pretty excited.
>>
>>58326225
function bits( str )
local num = tonumber(str)
return math.ceil(math.log(num)/math.log(2))
end
>>
>>58326426
I don't know this meme. Will it make GNOME stop leaking like crazy?
>>
>>58325805

def nigger(x,y):
x = x + 1
z = x + y
fag = ((z*z + z)/2)-y
return int(fag)

asd = ""
for y in reversed(range(10)):
for x in range(10):
asd = asd + str(nigger(x,y)).zfill(3) + " "
print(asd)
asd = ""
>>
>>58326446
That's assuming the number fits into your numeric type!
*hands your function a VERY long string*
>>
>>58326476
Nope, I actually got the fastest possible
def answer(x, y):
n = x + y + 1
n * (n + 1) // 2 - y
>>
>>58326476
whats this?
>>
>>58326454
Well, this is them putting a toe in the water. It's hardly jumping in. The good news is you have to go out of your way to leak in Rust. Basically you need to either have a reference counted cycle, or do something stupid by using something like std::mem::forget()
>>
>>58326488
>type
>python
>>
>>58326523
hmmm what's python
>>
>>58326523
pls be troll
>>
>>58326488
Looks like Lua can handle up to about 1024bit numbers, after that it's INF
>>
>>58326606
Lua uses doubles for its numbers.
>>
File: 1483553528769.jpg (142KB, 567x437px) Image search: [Google]
1483553528769.jpg
142KB, 567x437px
tell me why LLVM is inferior to GCC or the kot gets it
>>
>>58326652
lua 5.3 and up has integers, too, although they are abstracted away.
>>
>>58326659
>GCC supports languages that clang does not aim to, such as Java, Ada, FORTRAN, Go, etc.
>GCC supports more targets than LLVM.
>GCC supports many language extensions, some of which are not implemented by Clang. For instance, in C mode, GCC supports nested functions
>>
>>58326711
>such as Java
GCC dropped Java support
>>
>>58326747
ok
>>
>>58326652
Must be using 2 doubles in extreme size numbers?
>>
>>58326810
I meant to say that it must split very large numbers across multiple doubles (seemingly up to max 16?)
>>
>>58326606
THE OBSERVABLE UNIVERSE!
>>
#include <stdio.h>
int
main
(void)
{
printf
("Hello ");
printf
("world!\n");
return
0;
}
>>
>>58326834
The IEEE double-precision floating point number can represent numbers up to 1.7976931348623157 * 10^308. If stored as an integer, this would be 1024 bits.

So, no. It uses only one.
>>
>>58326923
This is a very aesthetic indentation scheme.
Could you show me a FizzBuzz example using it?
>>
File: KaiAndElites.png (759KB, 1500x1025px) Image search: [Google]
KaiAndElites.png
759KB, 1500x1025px
Do I want to implement bitwise instructions or shift/rotate instructions for my VM next?
>>
>>58326926
"IEEE 754". Forgot a number.
>>
SOMEBODY CLONED MY SHIT
>>
>>58326958
This is not absolute optimum
>>58326507
That is literally the fastest way possible.
>>
>>58326962
>tfw 4 unique visitors.
>>
>>58326926
Ah, it rounds out the ends
>>
File: CSC231RangeOfFloats.jpg (47KB, 595x391px) Image search: [Google]
CSC231RangeOfFloats.jpg
47KB, 595x391px
>>58327048
Yes, doubles (and ofc floats too) are less precise at the ends of their range.
>>
>>58327082
Yeah I just got confused about the output one of the scripts made, made it seem like it was a monstrous int. (i printed the original string)
>>
>>58327002
yeah I don't really remember what I was thinking when I posted that already
it's really late and I feel dumb now
I was going for that exact solution at the beginning and it ended up as a cheap hack with for loops
why did I do all that, I don't remember
>>
>>58325820
So's SHA256 and Twofish, but Intel doesn't support either.
>>
>>58327177
SHA256 is not the standard, there is no standard hashing. Twofish is not used.
>>
>>58326946
Bitwise is probably more important.
>>
>>58327211
Blowfish is used a lot?
>>
>>58326962
Mom made an account to cheer you up.
>>
>>58327233
Your mom blows a lot.
>>
>>58327264
>>58327254
Great minds think alike, eh?
>>
>>58327233
No. Nothing besides AES is very used. When other things are used they are used together with AES.
AES has been more audited, but those other ciphers are probably as secure. They are usually just slower.
>>
>>58327027
>>58326962
the NSA did that of course
>>
File: 1367077035585.png (222KB, 600x400px) Image search: [Google]
1367077035585.png
222KB, 600x400px
>>58325678
Stop using one of my images to start a thread on /g/, you autist.

This image has nothing to do with Programming even.
>>
type(5.0 + 1)


why is the type 'float' and not 'int'?
is there an order of operations (beside the obvious) in Python too?
>>
File: jojo reference.png (4MB, 3840x2400px) Image search: [Google]
jojo reference.png
4MB, 3840x2400px
Trying to learn SDL/AnyFuckingGraphicsLibraryForC++AtThisPoint

I'm following this tutorial http://lazyfoo.net/tutorials/SDL/02_getting_an_image_on_the_screen/index.php
but using a PNG (and so am using the SDL_image library), but the only way the image loads properly is if I fullscreen the window (as in pic related)

Is there an easy way to resize the image/window to make it fit?
>>
>>58327492
Because it would be insane if floats were constantly checked to see if they're integers and then converted if so. 5.0 is a float, 5 is an int.
>>
>>58327492
int gets promoted to a float so that it doesn't lose information. Imagine if you had an operation like 5.7 + 2 and the 5.7 was cast to an int.
>>
>>58327530
>>58327556
that makes sense, thanks lads.
>>
>>58327338
Shup up, freetard.
>>
File: Troubleshooting_SDL.webm (361KB, 1488x1472px) Image search: [Google]
Troubleshooting_SDL.webm
361KB, 1488x1472px
Question: Why does this happen? I'm trying to resize an SDL Window with an image in it, but the moment I resize it, the screen goes black...

Here's my source code: http://pastebin.com/TLEYQPnH
>>
>>58327496
You can draw it scaled or you can get its dimensions and use them to set the window's size.

>>58327868
Are you continuously drawing it?
>>
Why aren't there any cute ide's?
>>
>>58327868
Here I fixed it: [ONLY REGISTERED USERS CAN VIEW LINKS]
>>
Is go the latest meme language or should I actually learn it
>>
>>58328006
Ayy le mayo
>>
>>58327986
the same reason there are no cute fat women
>>
>>58328108
Theres nothing inherently uncute about ides
>>
>>58328186
What do you mean by cute?
>>
>>58328206
Cute. Like moebuntu
>>
I made a "2d shift register" which is displayed on the left in this image to see what it would do

it has horizontal and vertical shifts

it does these shifts in an order from top to bottom left to right from the array on the right to the column/row they appear

how do I make sense of what the hell it is actually doing? seems pretty chaotic
>>
>>58325678
>posting the level zero slut
>>
File: 1389224279388.jpg (44KB, 500x316px) Image search: [Google]
1389224279388.jpg
44KB, 500x316px
What's the best way to pass a large amount of arguments to a method in C#?
I have a custom camera rendering method that currently looks like this
Vector3 eyePos, string textureName, Material material, Matrix4x4 viewMatrix, RenderTexture rt, MeshRenderer targetRenderer, Mesh mesh, bool optimize = false,  bool obliquePlane = true

and I'd like to clean it up.
>>
>>58328525
you can make class for all that arguments
>>
is this a good first book https://www.amazon.com/Head-First-Java-Kathy-Sierra/dp/0596009208/ref=sr_1_2?ie=UTF8&qid=1483581433&sr=8-2&keywords=java
>>
>>58328525
Redesign it.

Vector3 eyePos

This could probably be a instance variable.

string textureName, Material material

???
The texture isn't a part of your Material?
Why is this being passed into your camera?

Matrix4x4 viewMatrix

Why is this being passed to your camera?
Is this supposed to be the "model" matrix?

RenderTexture rt, MeshRenderer targetRenderer

This shouldn't be part of the camera.
It should be part of your renderer.

Mesh mesh

Maybe pass the model matrix here instead of the mesh?

bool optimize = false

what the fuck does this parameter even do

bool obliquePlane = true

why does it exist
>>
>>58328638
>https://docs.oracle.com/javase/tutorial/
>>
Does anyone have a pdf of kernighan's go book?

Also, how useful is it to just read a language's specification to understand it?
>>
>>58328643
>This could probably be a instance variable.
It changes every frame
>The texture isn't a part of your Material?
>Why is this being passed into your camera?
The texture is part of the material, but the material may have more than one texture so it may be called multiple times with different parameters on the same material.
>This shouldn't be part of the camera.
>It should be part of your renderer.
It is part of the camera- the camera is being rendered through a "window", which is that mesh. The mesh is not being rendered onto.
>maybe pass the model matrix
That was actually a fuckup on my part, that param has been removed as the info derived from it can be derived from the meshrenderer now.
>what the fuck does this parameter even do
It optimizes the render using matrix/camera fuckery. It's USUALLY a good idea to use it, but since Unity's occlusion culling is completely fucked for askew matrices it would actually run slower if it were to be optimized on gigantic scenes.
>why does it exist
you might not want the camera's near plane to be cut off for certain effects
>>
>>58328734
can't you split it in smaller functions?
>>
>>58328771
I mean, I could, but it wouldn't really make any sense to. One function for "Render the textures for this frame into the material" makes sense to me.
>>
>>58325752
Mfw clover still has (You)s
Also check em
>>
>>58328525
public DataTable GetDataTable(ApplicationUser user, bool showNotApproved, bool onlyEditable, List<string> sections, List<long> primaryRelations = null, List<long> secondaryRelations = null, DateTime? reportDate = null, IList relatedObjects = null, DateTime? changeDate = null, DateTime? formalDate = null)


I dont get whats your problem
>>
>>58328855
I bet the people on your dev tream just love you.
>>
File: Untitled 1.png (20KB, 1251x349px) Image search: [Google]
Untitled 1.png
20KB, 1251x349px
Im making a vive vr game for blender. Ive got tracking working a few lines above this but I cant get video sent out to the vr compositor.

This:

openvr.VRCompositor().submit(openvr.Eye_Right, y)

is responsible of sending video to the right eye of the vive. The "y" bit shuold be taking a ctype "byref" value. How would I convert a texture stored as a python variable to this "byref" value?

Im using the pyopenvr python bindings for steamvr but I'd appreciate any tips from C people.
>>
File: 1479596863096.png (20KB, 640x480px) Image search: [Google]
1479596863096.png
20KB, 640x480px
> he has to hardcode his debug code into his functions
>>
File: 1452471092796.png (372KB, 1280x720px) Image search: [Google]
1452471092796.png
372KB, 1280x720px
>>58328953
>He posts frogs
>>
>>58328910
>having a job
I want normies to leave.
>>
>>58328855
public DataTable GetDataTable(ApplicationUser user,
bool showNotApproved,
bool onlyEditable,
List<string> sections,
List<long> primaryRelations = null,
List<long> secondaryRelations = null,
DateTime? reportDate = null,
IList relatedObjects = null,
DateTime? changeDate = null,
DateTime? formalDate = null)
>>
File: 3123590-8969278676-batma[1].jpg (42KB, 400x250px) Image search: [Google]
3123590-8969278676-batma[1].jpg
42KB, 400x250px
>>58328910
I can take it.
Im not a hero.
Im a silent guardian, a watchful protector.


A dark knight.
>>
>>58328699
pls
>>
>>58326659

Kot... a misspelling of cot (bed)? You should probably move the feline before you open fire on that cot.

>>58326711

Clang and clang++ are not compiler collections, they C and C++ compilers respectively that target LLVM IR. They are not, however, the only LLVM IR compilers around, and there do exist LLVM front ends for Ada and Fortran. These would be the equivalents to Clang for these languages. I don't think there's a Java compiler for it, but I'm not sure if anyone wants to make one.

The point about GCC supporting more targets is a valid one, however this will change over the next few years. LLVM is a lot easier to port and maintain for new platforms. Its ease of use is why EmScripten uses Clang and LLVM, rather than writing a port of GCC.

Many GNU C extensions are available in Clang, but I suppose nested functions are not among them. That said, no one with a brain uses them.
>>
>>58329075
"kot" is "cat" in most slavic languages
>>
>>58329109

We speak English here on 4chan.
>>
>>58329279
ZmuÅ› mnie
>>
>>58328953
>he has to debug
>>
import Data.List

prizes = [ ((5,True) , "grand")
((5,False), "million")
((4,True) , "fifty-k")
((4,False), "hundred")
((3,True) , "hundred")
((3,False), "seven")
((2,True) , "seven")
((1,True) , "four")
((0,True) , "four")
]

>this isn't allowed in haskell
m e m e
>>
>>58329373
Everyone has to debug. Compilers can detect type errors, but not outright logic errors. If a program compiles, it will do what you said it to do, but not necessarily what you intended it to do.
>>
I guess I should have posted this >>58329221 in here.
>>
>>58329506
>he makes logic errors
>>
>>58329641

Everyone makes logic errors. That's why debuggers exists in the first place.
>>
>>58329796
>he responds to that low quality troll
>>
>>58329838

>he responds to a tripfag
>>
>>58328953
but I don't, Anon
type Unit_Vector is record
X : Vector_Component;
Y : Vector_Component;
end record
with Dynamic_Predicate => Sqar(Unit_Vector.X) + Sqar(Unit_Vector.Y) = Vector_Component(1.0);

procedure Swap (Item : in out Unit_Vector) with Inline, Post => Item.Y = Item.X'Old and Item.X = Item.Y'Old is
Temp : Vector_Component;
begin
Temp := Item.X;
Item.X := Item.Y;
Item.Y := Temp;
end Swap;
>>
>>58329861
kek
>>
File: 1448742525524.jpg (24KB, 300x250px) Image search: [Google]
1448742525524.jpg
24KB, 300x250px
>>58329882
>Dynamic_Predicate
>that verbosity
>>
>>58329989
It's fine since I type with more than two of my fingers
>>
akari bbs is kill
>>
>>58330025
>homegrown c textboard
stillborn would be the word
>>
What's sin tan and cos used for when programming games/animations?
>>
>>58330089
Going between cartesian and polar coordinates.
>>
>>58330089
>didn't pass trig
>>
>>58326923
Terrible, use putchar() for the newline and getchar() to make sure the program pauses for windows users, so it's portable
>>
>>58330089
uh. math?
>>
>>58325840
You're just a flake
Try harder
Taking drugs will just make you a flake on drugs
>>
>>58330089
mainly rotating matrices, but a few other things as well.
>>
>>58325840
I never understood why people took adderall in college. Most of the stories they told me about it had them mostly wasting their time, since they either lost their attention span or got incredibly focused on cleaning their room or some shit.
>>
1 out of 10 people know binary, the other half don't XD
>>
>>58330719
i got the entirity of my poker games logic down. might put the poker project aside though and start learning a new language.

['10s', 'As']
['Ks', '5d', 'Qs', 'Qd', 'Js']
royal flush
['10s', '9s']
['2d', 'Js', 'Kd', 'Qs', '8s']
straight flush
['7s', '8h']
['9d', '7d', '7c', '7h', '4c']
quads


that was searching for all the quadsd, sflushes, and rflushes in 2,000 hands kinda cool how them deals ouptutted one of each.
>>
>>58330515
Never did adderall mainly smoked meth. My productivity was through the roof until I was caught stealing another students mac book and all my financial aide was dropped.
>>
>>58330897
not sure what to take away from this story
>>
File: cute anime pic 0319.jpg (119KB, 1280x720px) Image search: [Google]
cute anime pic 0319.jpg
119KB, 1280x720px
>gcc update
>on Gentoo
>>
File: 2017-01-04 22_18_00.png (9KB, 1024x600px) Image search: [Google]
2017-01-04 22_18_00.png
9KB, 1024x600px
OpenGL/C++/GLEW

I'm using VBO and GL_LINE_STRIP and glDrawElements

Why does it draw a line back to 0,0 every frame? I checked my array of vertices and 0,0 isn't in it
>>
>>58331039
Any indices out of bounds?
>>
>>58331054
No, and I'm doing a fade effect so i'm basically storing the last 10 to 20 iterations of the oscilloscope and fading them out. Hence why i need to draw so many lines

All 10 (or 20, however many i choose) iterations all have a line going back to 0,0
>>
File: 2017-01-04 22_25_05.png (58KB, 1024x600px) Image search: [Google]
2017-01-04 22_25_05.png
58KB, 1024x600px
>>58331081
This is without the fade effect obviously but as you can all 10 have that line
>>
#include <iostream>

int mult ( int x, int y )
{
return x * y;
}

int main()
{
mult( 5, 6 );
}


why does this not print multiples?
>>
>>58331115
Because you're not printing anything
>>
>>58331115
because you didn't tell it to malakas
>>
>>58331115
All you did was return the value; you need to either store the result into an integer or call print on the mult method.
>>
>>58331115
http://en.cppreference.com/w/cpp/io/cout
http://en.cppreference.com/w/cpp/io/c/fprintf
>>
>>58330515

They take the drug because they have no ability to focus on their work. Because this is actually a function of bad habits and not an actual mental disorder, the drug therefore causes them to hyperfocus on doing things other than their homework and they fail the class anyways.

I'm not a perfect student. My GPA right now is a fucking 3.5 for my master's, and it was a little less for my bachelor's. Most of my classes are project based, and the time period of ten weeks from the start of the class to the end of dead week does not make it easy to get things working perfectly. I sometimes do shitty on tests when I make bad judgment calls on what will be covered the most. Regardless, I still put in as much fucking effort as I can to my classes, and don't need to resort to drugs to pull shit off. Some people are just weak willed.

>>58331115

You are multiplying 5 and 6 and throwing the result on the floor. Maybe you should put in a cout statement or something...
>>
>>58331101
can see*

Also, I am making 10 calls to glDrawElements, not just one. so 10 separate vertex buffer objects, etc
>>
>>58331157
Post your vertex buffer, your index buffer and all the opengl-related C++ code
>>
>>58331054
wait maybe it is going out of bounds, would that cause this behavior? i will check
>>
File: firefox_2017-01-04_21-32-00.png (45KB, 567x488px) Image search: [Google]
firefox_2017-01-04_21-32-00.png
45KB, 567x488px
when i want merge a branch to master, which merge should i do or what circumstances would i do anything but the last one
>>
>>58331178
the index buffer should just be an array counting from 1 to n number of indices correct?
>>
>>58325840
boooooooooooo


just use water. lots of water.
>>
>>58331181
I don't know what OpenGL is supposed to do when an index is out of bounds but drawing a vertex at 0,0 seems plausible.

>>58331205
0-indexing.
>>
>>58331234
sorry, yeah 0 to n-1 right?
>>
>>58331240
Yes.
>>
>>58325840
high doses of caffeine do the job for me.
>>
>>58331205
not necessarily, it depends on what you're trying to do, but yes, since all you want to do is draw sequential lines that seems about right

but why aren't you using glDrawArrays instead? since there's no repeated vertices, using glDrawElements is just adding an extra level of indirection needlessly

or to rephrase it: you have vertices A, B, C, D, E. You want to draw lines AB, BC, CD, DE. Since the vertices are already ordered and none of them repeat, there's no gain by instead telling the computer that there are vertices 1:A, 2:B, 3:C, 4:D, :E and you want to draw lines 12, 23, 34, 45

I realise this might not be completely clear so don't be embarassed to ask me to explain better
>>
>>58331267
Ah ok I didn't know the difference between glDrawArrays an glDrawElements, i think i get what you're saying though

i think i found the problem, i was using a #define from when i was testing to set the size of the array which was a different value than the number of audio samples i'm actually using. i think that's exactly what's happening - out of bounds
>>
>>58331234
>>58331267

oh wait. my vertices array should be twice the size of the indices away since each vertex is x,y right? if i have 804 elements in the vertex array (x,y pairs) i should have 402 indices?
>>
>>58331386
You shouldn't even be using indices at all if you're just going to do 0, 1, 2, etc. But yes, if you've got 402 vertices (where each vertex is two elements) you should have 402 indices.
>>
>>58331408
ok i'll switch it over to gldrawarrays
>>
>>58325678
L E V E L 0

0
>>
>>58331408
Nice, glDrawArrays is much easier, and no line going back to center. It probably had something to do with going out of bounds but fuck it this works.

Thanks anon
>>
>>58331456
>but fuck it this works
This is a bad attitude. If something works but you can't explain why/how, then it's just a coincidence. Try to make glDrawElements work as well.
>>
apparently im retarded because i cannot comprehend how this says "1337" in binary

10100111001

someone help me understand this shit
>>
>>58331479
i knowwwwwwwwwww i'm just lazy


ok i'll try to make it work
>>
>>58331497
"Binary" is just a number base. It has no inherent meaning/"translation" to regular characters. It all depends on what encoding (assignment from binary numbers <-> characters) you're using. We can't help you unless you tell us what encoding that string of 1's and 0's is in, but if you're assuming it to be ASCII (the "regular" encoding), then it doesn't say "1337".
>>
>>58331497
http://www.binaryhexconverter.com/binary-to-decimal-converter

it explains it below
>>
>>58331522
>>58331526

Never mind, I just realised he meant 1337 and not "1337".
>>
>>58331497
think of counting with base 10 (10 digits, 0-9), you count 0,1, 2, 3, 4, 5, 6, 7, 8, 9... uh oh, you're out of digits, so the ones place roles over to 0, and the tens place starts at 1... .10, 11, 12, etc

count with base 2 (2 digits, 0 and 1) 0, 1... uh oh out of digits! ones place roles over to 0, twos place (i might be calling these the wrong "place") changes to 1. so 10, 11, uh oh out of digits. ( you run out of digits much more often when you only have 2) ones place rolls over to 0, twos place rolls over to 0, threes place is now 1 so... 100, 101, 110, 111, etc etc


that's what you need to understand before moving forward with number bases
>>
File: Skellyman.jpg (71KB, 499x562px) Image search: [Google]
Skellyman.jpg
71KB, 499x562px
>>58327920
I mean... I think I am?

Honestly the best solution at this point would be to just not allow a resizable window

if( !loadMedia() )
printf("Failed to load media!\n");
else
{
//Update Surface
SDL_Delay(5000);
bool quit = false;
SDL_Event e; //Event handler;

//While app is running
while (!quit)
{
loadMedia();
SDL_BlitSurface(gImage, NULL, gScreeenSurface, NULL); //Apply Image
SDL_UpdateWindowSurface(gWindow);
while (SDL_PollEvent (&e) != 0)
{
if (e.type == SDL_QUIT)
quit = true;
}
}
}
>>
>>58331580

i understand that with 8 bits (1 byte) you can have up to 256 possible combinations of 1's and 0's but still not getting how it spells out words and num.

10100111001

there's 11 bits there? wtf?
>>
>>58331751
it's not "spelling out words", 10100111001 in binary converts to the number 1,337 in decimal
>>
>>58331751

also i looked up a chart and it says 111 means the number 7. But with "1337" the 7 is at the end. Why isn't the 111 at the end of this then?

10100111001
>>
>>58331772
An alternate way of writing 1337 with ones and zeroes is 1001100110111. This is like you suggest (0011 = 3, 0111 = 7).

It's called "binary coded decimal" and no one's done it since 1980 because it's trash.
>>
>>58331751
It IS numbers.

Read it backwards in base 2 -> base 10. 2^0 = 1, skip^1, skip^2, 2^3 = 8, 2^4 = 16, 2^5 = 32, skip^6, skip^7, 2^8 = 256, skip^9, 2^10 = 1024.

1 + 8 + 16 + 32 + 256 + 1024 = 1337.
>>
What resources should I consult if I want to program a realtime audio to midi converter? I have a decent amount of programming experience, but have never done anything with audio.
>>
>>58325678
What's everyone's favorite color scheme? Reformatted and thinking of moving from solarized dark
>>
>>58331894
Dark like my soul, because it's also easy on my eyes
>>
>>58331894
dark like i like my men
>>
File: derp.png (33KB, 1024x600px) Image search: [Google]
derp.png
33KB, 1024x600px
>>58331772
>>
>>58331894
>>58331908
>>58331925
Dark what though?
>>
>>58331958
i use vs2015 dark theme
>>
>>58331955

k thanks guys i really need to study this shit some more i even forgot why 2^0 = 1
>>
File: danny_devito-300x225.jpg (13KB, 300x225px) Image search: [Google]
danny_devito-300x225.jpg
13KB, 300x225px
>>58331995
>>
Very new to programming here.

What is the secure printf?

printf_s is not working as the book says
>>
>>58331894
Gruvbox with hard dark background (dicks lol) is my favourite.
>>
>>58332017
>printf_s
Never heard of it, but I'm guessing it's talking about not doing something like this
char buffer[1024];
...
printf(buffer);

due to it being a possible security vulnerability. Look up string format vulnerabilities. I guess printf_s is a way to avoid it
>>
File: 1482136971148.png (52KB, 897x233px) Image search: [Google]
1482136971148.png
52KB, 897x233px
>>58332112
Can you explain me this, please?
>>
>>58332157
http://stackoverflow.com/questions/9548979/format-string-vulnerability
tl;dr just use fgets() if you want to be careful
>>
Figured making a new thread wasn;t worth it and would get close to 0 replies.
I started culminating the things I've worked on during school on my github.
I've been looking at other github projects and wondered if /g/ had any. Didn't see any github threads or any github articles on the wiki (linked on the sticky).
I'm guessing no one wants to link their github so their repos don't get memed on, but the idea of working on something together, even if it's stupid as fuck, seems like fun. Version control would be a nightmare.
I've been interested in contributing to something, but not sure what.
>>
>>58332464
My name is on my GitHub. I'm never posting it.
>>
File: 1467006362795.jpg (10KB, 278x300px) Image search: [Google]
1467006362795.jpg
10KB, 278x300px
I want to make a cross platform (Android, iOS, Windows, Linux, OSX) application. Basically it'll sync the notifications and reminders etc.


Is Java my ONLY option?
>>
>>58332540
Android and iOS can use C++ yo
>>
>>58332647
Anon I want to suck your cock. Thanks
>>
>>58332540
C#/xamarin may do
>>
>>58329861
>he hastily opens 4chan to read the (You) he just got
>>
>>58332540
Scala and Clojure run on the JVM.
>>
>>58325805
(i^2+j^2+2ij+3i+j+2)/2
>>
>>58333330
almost nice digits
>>58333333
>>
>>58326507
>>58333330 (me)
aww nigga'd
>>
>>58325733
Textadept.
>>
How do I get near and far to work correctly in a projection matrix when I'm using the following vertex shader?
void main() {
colour = vertexColour;
vec4 position = matrix * vec4(vertexPosition, 1.0);
gl_Position = vec4(position);
}


The vertex shader used to say gl_Position = vec4(position.xy/position.w, position.z, 1.0) and when it was like that the near and far cutoffs were fine but it had some bugs.
>>
>>58333709
What do you mean? Near and far are just the near and far clipping planes, i.e. how close things can be before they get cut off, and how far they can be
You shouldn't need to modify any part of the vertex shader
>>
>>58333729
Well, my near and far clipping planes aren't working.
Near objects are getting cut off too early, far objects never seem to cut off.
>>
>>58333746
Then change the viewing planes
>>
>>58333757
I have no idea what you're talking about, I'm not using a library, it's largely guesswork maths all the way down.
>>
>>58333853
What libraries are you using?
>>
>>58333757
*clipping planes
>>
>>58332540

If it syncs, it needs to use the Internet.
Have you considered a web-application?
>>
>>58332464
>but the idea of working on something together, even if it's stupid as fuck, seems like fun

I'll make the logo.
>>
>>58334075
I'll write the CoC
>>
>>58332464
Make a decentralized version control that focus on simplicity: changes are nodes and projects are signed paths.
>>
>>58333888
>I'm not using a library
>What libraries are you using?
>>
I have a C++ library to load a file and a "LoadFromFile" function. How should I report specific errors to the user that calls this function.
Exceptions? Error codes? Error Strings?
>>
>>58334325
Option types.
>>
>>58334325
ExceptT monad transformer
>>
>>58334325
There's no one good way.
>>
Programming isn't fun anymore.
>>
>>58334467
>t. code artisan
>>
>>58334467
Try cooking, it's similar.
>>
>>58334467
When I get bored of programming, I just watch a bunch of chinese cartoons.
>>
>>58334498
Does that help?
>>
>>58334467
learn Haskell
>>
>>58334467
It never supposed to be.
>>
>>58334521
Yes
>>
>>58334545
What kinds of problems would i use Haskell for?
>>
>>58334571
https://github.com/Gabriel439/post-rfc/blob/master/sotu.md
>>
>>58334467
this

it's only fun to see results/progress... when you get stuck it can go fuck itself
>>
@ people in programming jobs: how long did you spend learning and what was your first job?

Britbong thinking about learning HTML/CSS/JavaScript and seeing if I can find a job with those. Wasted my degree years so now I'm looking to fix that.
>>
>>58334706
> Britbong thinking about learning HTML/CSS/JavaScript and seeing if I can find a job with those.

You can do better than that.
>>
>>58334706
wrong thread. your kind isn't welcome here
>>
>>58334727
Can you recommend something better, in that case? It would be my first language.
>>
>>58334735
I recommend Haskell
>>
>>58334706
>wasted my degree years
>learning HTML/CSS/JavaScript
Well memed anon.
>>
>>58334735
https://docs.oracle.com/javase/tutorial/
>>
>>58334745
>Java
(You)
>>
>>58334735
No learn Javascript and browse >>>/g/wdg/.

/dpt/ is full of idiots.
>>
>>58334735
Haskell

Haskell From First Principles
https://0x0.st/pbp.pdf
>>
>>58334735
Start with C, and then move on to C++/C#/Java, you can't go wrong with these.
>>
>>58334757
nicely meme'd, friend
>>
>>58333893
The problem is that the clipping planes aren't where they're supposed to be.
If I say they should be 10 units away, that's not what it'll be. In fact, I'm pretty sure ithere isn't distant object clipping at all.
>>
>>58334765
>Start with C, and then move on to C
fixed that for you
>>
>>58334775
Are your transformations right?
If you're in a normalised co-ordinate space (e.g. 0 to 1 xyz) then 10 won't clip
>>
>>58334798
Let's not get crazy.
>>
>>58334765
>>58334798
Can I use Eclipse as a development environment for these?
>>
>>58334811
yes
>>
>>58334811
Eclipse is garbage.
>>
>>58334816
only if you have too little ram, idiot
>>
File: white_square.png (128KB, 401x401px) Image search: [Google]
white_square.png
128KB, 401x401px
>>58334808
><
>>
File: imagem015.jpg (152KB, 1280x720px) Image search: [Google]
imagem015.jpg
152KB, 1280x720px
test went well, hope to have aced it
>>
>>58334811
IDEs are useless garbage, especially for C, especially eclipse
>>
Don't start with C. Start with C++.
>>
>>58334837
What were the questions and your answers?
>>
File: 1483528151331.gif (3MB, 512x288px) Image search: [Google]
1483528151331.gif
3MB, 512x288px
>>58334842
>>
>>58334837
I like your clothes. :3
>>
>>58334846
>I have never made anything in C but I learned the memes very carefully
>>
>>58334846
C++ is absolute garbage. Nobody should be subjected to that shit.
>>
>>58334864
And still it is the best general purpose language out there.
>>
>>58334886
this
>>
>>58334864
It's not, but it's not a beginner language.
>>
File: go_lang1.png (58KB, 607x318px) Image search: [Google]
go_lang1.png
58KB, 607x318px
I'm trying out Go. What should I write that'll help me learn the language?
>>
>>58334886
>>58334893
>>58334897
Same IQ
>>
>>58334904
It's okay if it turned out to be too hard for you. :^)
>>
>>58334901
polymorphic entity-component system with generic data store
>>
>>58334901
>I'm trying out Go.
y tho
>>
>>58334901
> I'm trying out Go.
Why would you do that? Even /dpt/ agrees it's shit.
>>
>>58334911
Yep, it's amazing how stupid people can't think simple.
>>
>>58334897
It's actually a pretty good beginner language.
>>
>>58334897
No, he's right, C++ IS garbage
>>
>>58334919

why?
>>
>>58331198
1st and 3rd are the only acceptabel solutions.
>>
>>58334953
- GC.
- No generic.
- Outdated type system.
- No ADT.
- No pattern matching.
- Not enough functional stuff.
- No RAII/IDisposible/Context managers.
- Ugly syntax.
- The most retarded and unsafe error handling story after C.
- NIH infrastructure with authors spending years reinventing stuff instead of using LLVM.
- Community comprised by mostly python-kiddies.
Overall the language was designed to be as simple as possible and then even more simple so Google can train code-monkeys on an industrial scale, the only good thing about it being coroutines.
>>
>>58335044
How about Rust?
>>
>>58335079
unsafe {
// How about Rust?
}
>>
>>58335091
>>58335044

do you people like anything other than C?
>>
>>58335079
It has somewhat ugly syntax, but overall it's much better.
>>58335114
I actually like Rust, it's cute.
>>
auto* ptr = new auto{ 3.14 };


>tfw you never thought about using auto in that context
>>
>>58335114
i like C++ and java

inb4 (You)s by the butthurt C/haskell autists
>>
>>58335127
Can't wait for C++30
auto auto(auto auto) {
auto<auto> auto = auto(auto)[auto];
if (auto > auto) {
auto += auto;
}
return auto;
}
>>
>>58335155
It almost writes itself!
>>
@58335139
somehow i'm not surprised that you like utter shit
>>
>>58335114
I actually prefer Rust, but I've been using it since well before it's release. I almost never hear the borrow checker, so that might be making it more pleasurable to write in.

That said, they need to fix the stdlib so that it's easier to be generic over plain numbers. Doesn't come up too much in real programs, but I've missed it once or twice.
>>
>>58334852
hardest question was write a C program to get seconds and turn them into hours, minutes and seconds
>>
New thread:
>>58335192
>>58335192
>>58335192
>>
>>58335182
>@58335139
>not knowing how to reply
get out
>>
@58335221
a sepples and java fag doesn't deserve my (You)s
>>
>>58335155
This tickled me way more than it should have.
>>
>>58335139
>>58335139
>>58335139
Here are the (You).
>>
>>58329989
Verbose doesnt just mean long words. Stop throwing buzzwords around and read a fucking book.
Thread posts: 317
Thread images: 38


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.