[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]

C++ Help Needed

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: 33
Thread images: 4

File: C++.png (112KB, 2348x1298px) Image search: [Google]
C++.png
112KB, 2348x1298px
Im trying to make a game using C++ and GLFW. Im currently trying to use SOIL source code (I did include the files in my project) and for some reason there is a linking error. Can anyone tell me why this is?
>>
Cause C++ sucks ass.
>>
>>59076098
Are you using windows? I am and my libsoil is called libSOIL.lib. Also make sure you use the right version depending on if you are targeting 64 or 32 bit.
>>
>>59076173
also
>GetHieght();
>>
>>59076190
Its defined in the cpp file
>>59076173
Im using windows. I auto completes and everything. Im not sure where this error is coming from.
>>
File: ANDURS.png (33KB, 154x155px) Image search: [Google]
ANDURS.png
33KB, 154x155px
>>59076098
C++ to male games in 2017
>>
OP make sure you have the libraries linked for both static and dynamic.

Go into the project settings and make sure they're linked. Right click on the project and go to its settings and show us the linker.
>>
>>59076208
hieght
>>
>>59076208
Where did you grab your libsoil? Did you compile it yourself?

recheck:
properties >linker>additional library directories
should have path to libsoild directory there
and
properties >linker>input>additional dependencies
should have libSOIL.lib there
>>
File: C++ lib.png (35KB, 834x593px) Image search: [Google]
C++ lib.png
35KB, 834x593px
>>59076225
Which thing do you need to see?
>>
>>59076260
>>59076260
This. I can't remember Winblows Visual Shitter, but aren't you supposed to link the static and dynamic libraries for debug and build options separately as well?
>>
>>59076098

don't use SOIL, there isn't any point
just use stb_image (which is what SOIL uses in the first place) and load the images yourself, it isn't hard at all
it's a header only library so it's easy to setup

Something like:
// opengl texture id
GLuint texture;

// get texture data from stbi
int w, h;
uint8_t* data = stbi_load("path goes here", &w, &h, nullptr, STBI_rgb_alpha);

// generate and bind opengl texture id
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_ID, texture);

// set the filter (use GL_NEAREST for pixel shit, GL_LINEAR for smooth shit)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

// set the wrap mode
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

// send data to opengl
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);

// unbind (bind again for later use)
glBindTexture(GL_TEXTURE_2D, 0);


also avoid `using namespace std` because it'll pollute the global namespace
consider passing by const reference too

also before including it be sure to define
STB_IMAGE_IMPLEMENTATION
at least once somewhere in your code
>>
>>59076275
Yeah kind of pointless to use SOIL when you can just setup its primary functions in about 30 minutes.

>>59076265
Under Additional Library Directories you'll want to type in the directory for the SOIL dependencies (and I think you'll have to do that for gflw as well).

Then you'll need to go to Linker > Input > Additional Dependencies and link crap like libSOIL.lib as this >>59076260 gentleman said.
>>
>>59076310
Alright So this is what The lib file i was given looks like in the file viewer. It appears to be a .a rather than .lib file and im not sure if that effects it.

If it is better to use something other that soil where can I go to learn how to setup the primary functions. Im new to opengl, alright at c++ and am pretty shit with visual studio so I was using SOIL because i dont know how to do what it does myself.
>>
>>59076374
Pretty sure .a libraries are for linux and mac. Your file should be libSOIL.lib.
>>
>>59076374
Just read the SOIL source code if you really want. It's a really dead simple library. I mean, it's whatever. You can use it, nobody cares. However, I think if you really want to learn OpenGL, you should be able to set up your own texture import library.

Look at what this guy posted:
>>59076275

He creates a texture ID, loads the texture file, and then does the basic texture buffer creation, binding, and coordinate mapping. You ideally would want to know this if you're serious about OpenGL. If you're not, just use some 3D graphics library. Also, Vulkan is the future fag. Get on the hype train or get left behind. :>)
>>
>>59076425
>.a libraries are for linux/mac
Dude, I knew something was fucking weird. I saw the .a outputs and yet I saw him using Visual Studio. I was going to post:

>.a
>winblows
Lel

But I thought I was retarded.
>>
>>59076098
I can already tell you suck at C++.

Please stop and use Java/Unity

Thanks.
>>
>>59076432
And OP, I know you're using open.gl as your reference. That guy actually has a Vulkan tutorial too and guess what:

https://vulkan-tutorial.com/Loading_models

stbi_uc* pixels = stbi_load(TEXTURE_PATH.c_str(), &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);


He doesn't use the libSOIL(MYSELF).
>>
>>59076470
Quite honestly I started out like OP just 5 years ago. I recommend he continues down this path. At least then he'll come to appreciate how fucking hard graphics programming is. Hell, I used to think library linking was the devil. Spent like 3 hours trying to get that shit to work back in the day.
>>
>>59076494
...Yep that is where im at right now. But its interesting atleast. Is there a lot of documentation on vulkan that I could use to learn it?
>>
>>59076511
There's the official Superbible for Vulkan:

>can't fucking link it so just go to libgen and look up "Vulkan Guide" and you'll see the link

I highly recommend the Vulkan Programming Guide book in that libgen link. It's pretty up to date so you won't be running into archaic dependency issues or trying to work their project files into your new IDE.
>>
>>59076494
>Hell, I used to think library linking was the devil. Spent like 3 hours trying to get that shit to work back in the day.
word

So many noob traps in just getting the libraries right alone. Outdated guides. Websites distributing random.libs .dlls that have god knows what in them. Then where to put the binaries. Oh wait actually you need to compile your own, install windows version of cmake, choosing the right architecture. Then there is the linking itself. Oh looks like you need a dll in the folder with your executable as well.
>>
>>59076374

you can find STBI and STBI_write on sjwhub
if you're new to opengl, you shouldn't need anything more than this for now. stick to the basics and work on the fancy APIs later

>>59076470
dude people gotta learn somehow lol get your ass back to plebbit

>>59076494
i guess this depends on what your goals are
if OPs goal is to make a game, he's wasting his time (unless he's smart and doesn't fall for the whole "make engine, not game" thing)
if OPs goal is to learn the basics of graphics programming, i'd say he's fine but still has a long way to go

on the subject of learning though...

honestly, you'd be better off doing this in c for now. c++ isn't as bad as everybody says it is, but really you want to focus more on learning the API itself and not how you can wrap everything up in it

instead of a texture class you'd just stick with something simple like
struct tex {
GLuint id;
GLint w, h;
} tex_t;


for the sake of minimalism

best of luck op. btw if you want my 2c i think vulkan is a little bit too new to start diving deep in but if you wanna go for it then by all means do so
>>
>>59076618
Linker and cmake issues are cancer. I'm surprised they don't have some kind of automated project solution that takes care of these problems. It really disincentives new programmers from learning. And I know what people will say:

>if you can't figure a fucking linker, how are you supposed to figure shader compilation?
My response is as follows: dumb ass IDE problems are a completely different ball game from the programming itself. Still, it's part of the ritual. You have to appease the linker and library gods before you're allowed to draw the satanic triangle.
>>
>>59076098
You know you the error you get is a linker error, yet you show some of your code as if that would help anyone find the error.
The error is most likely in your build system, so read your cmake or whatever you use and find the error there.
>>
>>59076647
>>if you can't figure a fucking linker, how are you supposed to figure shader compilation?

shader compilation takes only a few lines of code which can be easily understood with a bit of reading
figuring out linking is more a process of memorization and knowing your IDE
>>
>>59076621
>focus on C to wrap around the API
Not a bad idea honestly. C++ STD libraries are pretty decent (even with the flack they get), but you'll want to understand the API and not get lost on templates and RAII. However, there will simply be more documentation when programming in the C++ environment. This can either be a blessing or a curse depending on whether or not your solution to not understanding something is to copy paste.

>btw if you want my 2c i think vulkan is a little bit too new to start diving deep in but if you wanna go for it then by all means do so
Actually, Addison-Wesley released their OFFISHUL Vulkan Programming Guide and it's pretty fucking good. I have no idea if these are the Khronos approved methods for Vulkan development but it's not completely hopeless. I expect within a year that the Vulkan documentation will be on par with the OpenGL side. And I say this because there's a lot of deprecated and horse shit OpenGL guides out there that are as good as trash.
>>
>>59076683
>figuring out linking is more a process of memorization and knowing your IDE
Oh yeah I know that. I'm just playing devil's advocate. I actually do think that not knowing your IDE is perfectly acceptable even if you're planning on doing some low level programming. Though you should get used to the fact that you will have to google solutions that won't make sense. It's more of an exercise in patience and trial and error than anything else.

>shader compilation takes only a few lines of code which can be easily understood with a bit of reading
I should be more specific. Shader program creation, shader program linking, the shader code itself, passing it to the appropriate OpenGL objects, et cetera. I should have said "the shader pipeline" instead.
>>
>>59076647
meanwhile, in linux:

> apt install freeglut-dev
> ok now i can link against glut

windows: 0
linux: 9999
>>
>>59076621
(This is op on a different computer)

I want to make games. Not game engines unless necessary (Which it seems to be).

That is why I want to learn this.
>>
File: 1484017033344.jpg (51KB, 640x640px) Image search: [Google]
1484017033344.jpg
51KB, 640x640px
Relevant and non-shit online GL tutorials:

>Learning modern 3D graphics programming by Jason McKesson

What else?
>>
>>59076986
https://learnopengl.com/
Thread posts: 33
Thread images: 4


[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.