[ / / / / / / / / / / / / / ] [ dir / 27chan / anita / cop / flutter / lewd / rmart / tulpa / vichan ]

/agdg/ - Amateur Game Development General

AGDG - The Board
Winner of the 77nd Attention-Hungry Games
/x/ - Paranormal Phenomena and The RCP Authority

April 2019 - 8chan Transparency Report
Name
Email
Subject
Comment *
File
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Embed
(replaces files and can be used instead)
Oekaki
Show oekaki applet
(replaces files and can be used instead)
Options
dicesidesmodifier

Allowed file types:jpg, jpeg, gif, png, webm, mp4, swf, pdf
Max filesize is 16 MB.
Max image dimensions are 15000 x 15000.
You may upload 5 per post.


Welcome to AGDG, have you ever made a game?
See also: /ideaguy/ | /vm/

File: 1463901801100.jpg (441.21 KB, 1199x800, 1199:800, edu-oatcert.jpg)

3a35e7  No.26830

Hi guys,

I don't have time to be the lead programmer, or even a credited programmer in your game. But I can offer to solve small problems for you. Please credit nodev in your game instead.

Mainly C++/OpenGL/GLSL, but I can do Javascript or PHP as well.

I can also offer help and suggestions if you're trying to post on StackOverflow but the fucking question-nazis are stopping you from learning.

Here is a Variant type in C++ that I just finished. Although you may not need it, I hope that it is enough for you to know that I'm serious and happy to help you. It's recursive for both itself and it's use in classes. For example:


typedef Variant<int,bool,OwnType> RecursiveVariantType;
RecursiveVariantType v = 12;
RecursiveVariantType x.Set<RecursiveVariantType>(v); // can't use assignment because of copy-assignment operators

works and so does:


class X
{
Variant<int,bool,RecursiveWrapper<X>> m_data;
}

If you're wondering what I get out of this, I get to feel like I'm useful.

Full thing incoming.

3a35e7  No.26831


template<class T>
struct Tag
{
using type=T;
};

template<class X, class A, class B>
struct Substitute : Tag<X> {};

template<class X, class A, class B>
using SubstituteType = typename Substitute<X,A,B>::type;

template<class A, class B>
struct Substitute<A,A,B> : Tag<B> {};

template<class X, class A, class B>
struct Substitute<X&,A,B> : Tag<SubstituteType<X,A,B>&> {};

template<class X, class A, class B>
struct Substitute<X&&,A,B> : Tag<SubstituteType<X,A,B>&&> {};

template<class X, class A, class B>
struct Substitute<X const,A,B> : Tag<SubstituteType<X,A,B>const> {};

template<class X, class A, class B>
struct Substitute<X volatile,A,B> : Tag<SubstituteType<X,A,B>volatile> {};

template<class X, class A, class B>
struct Substitute<X const volatile,A,B> : Tag<SubstituteType<X,A,B>const volatile> {};

template<template<class...>class Z,class...Xs, class A, class B>
struct Substitute<Z<Xs...>,A,B> : Tag<Z<SubstituteType<Xs,A,B>...>> {};

template<template<class,size_t>class Z,class X,size_t n, class A, class B>
struct Substitute<Z<X,n>,A,B> : Tag<Z<SubstituteType<X,A,B>,n>> {};

template<class R,class...Xs, class A, class B>
struct Substitute<R(Xs...),A,B> : Tag<SubstituteType<R,A,B>(SubstituteType<Xs,A,B>...)> {};

struct OwnType {};


3a35e7  No.26832


template<typename... Ts>
class Variant;

template<typename T>
class RecursiveWrapper;

template<typename T0, typename... Ts>
struct VariantHelper;

template<typename T0, typename F, typename... Ts>
struct VariantHelper<T0, F, Ts...>
{
inline static void Destroy(const std::type_index typeIndex, void* data)
{
if(typeIndex == std::type_index(typeid(SubstituteType<F,OwnType,T0>)))
reinterpret_cast<SubstituteType<F,OwnType,T0>*>(data)->~SubstituteType<F,OwnType,T0>();
else
VariantHelper<T0,Ts...>::Destroy(typeIndex, data);
}

inline static void Move(const std::type_index oldTypeIndex, void* oldV, void* newV)
{
if(oldTypeIndex == std::type_index(typeid(SubstituteType<F,OwnType,T0>)))
new (newV) SubstituteType<F,OwnType,T0>(std::move(*reinterpret_cast<SubstituteType<F,OwnType,T0>*>(oldV)));
else
VariantHelper<T0,Ts...>::Move(oldTypeIndex,oldV,newV);
}

inline static void Copy(const std::type_index oldTypeIndex, const void* oldV, void* newV)
{
if(oldTypeIndex == std::type_index(typeid(SubstituteType<F,OwnType,T0>)))
new (newV) SubstituteType<F,OwnType,T0>(*reinterpret_cast<const SubstituteType<F,OwnType,T0>*>(oldV));
else
VariantHelper<T0,Ts...>::Copy(oldTypeIndex,oldV,newV);
}

inline static bool TypeIsValid(const std::type_index typeToCheck)
{
if(typeToCheck == std::type_index(typeid(SubstituteType<F,OwnType,T0>)))
return true;
else
return VariantHelper<T0,Ts...>::TypeIsValid(typeToCheck);
}

inline static bool TypeIsValidRecursiveCheck(const std::type_index recursiveWrapperType)
{
if(recursiveWrapperType == std::type_index(typeid(SubstituteType<F,OwnType,T0>)))
return true;
else
return VariantHelper<T0,Ts...>::TypeIsValidRecursiveCheck(recursiveWrapperType);
}
};

template<typename T0>
struct VariantHelper<T0>
{
inline static void Destroy(const std::type_index typeIndex, void* data){}
inline static void Move(const std::type_index oldTypeIndex, void* oldV, void* newV) {}
inline static void Copy(const std::type_index oldTypeIndex, const void* oldV, void* newV) {}
inline static bool TypeIsValid(const std::type_index typeToCheck) { return false; }
inline static bool TypeIsValidRecursiveCheck(const std::type_index recursiveWrapperType) { return false; }
};


3a35e7  No.26833


template<typename... Ts>
class Variant
{
public:

typedef Variant<Ts...> thisType;

Variant() : m_typeIndex(InvalidType()){}

Variant(const Variant<Ts...>& old) : m_typeIndex(old.m_typeIndex)
{
HelperType::Copy(old.m_typeIndex, &old.m_data, &m_data);
}

Variant(Variant<Ts...>&& old) : m_typeIndex(old.m_typeIndex)
{
HelperType::Move(old.m_typeIndex, &old.m_data, &m_data);
}

template<typename T>
Variant(const T& value) : m_typeIndex(std::type_index(typeid(T)))
{
Set<T>(value);
}

Variant<Ts...>& operator=(Variant<Ts...> old)
{
Variant<Ts...> temp(*this);
m_typeIndex = old.m_typeIndex;
HelperType::Copy(old.m_typeIndex,&old.m_data,&m_data);
old.m_typeIndex = temp.m_typeIndex;
HelperType::Copy(temp.m_typeIndex,&temp.m_data,&old.m_data);

return *this;
}

template<typename T>
bool Is() const
{
return (m_typeIndex == std::type_index(typeid(T)));
}

bool IsValid() const
{
return (m_typeIndex != std::type_index(typeid(InvalidType())));
}

std::type_index GetTypeIndex() const { return m_typeIndex; }

template<typename T>
Variant<Ts...>& operator=(const T& rhs)
{
Set<T>(rhs);
return *this;
}

template<typename T, typename... Args>
void Set(Args&&... args)
{
if(!HelperType::TypeIsValid(std::type_index(typeid(T)))
&& !HelperType::TypeIsValidRecursiveCheck(std::type_index(typeid(RecursiveWrapper<T>))))
throw std::logic_error("Type not supported in Variant template (" + std::string(typeid(T).name()) + ")");

HelperType::Destroy(m_typeIndex,&m_data);
m_typeIndex = InvalidType();

if(!HelperType::TypeIsValidRecursiveCheck(std::type_index(typeid(RecursiveWrapper<T>))))
{
new (&m_data) T(std::forward<Args>(args)...);
m_typeIndex = std::type_index(typeid(T));
}
else
{
new (&m_data) RecursiveWrapper<T>(std::forward<Args>(args)...);
m_typeIndex = std::type_index(typeid(RecursiveWrapper<T>));
}
}

template<typename T>
operator T() const { return Get<T>(); }

template<typename T>
const T& Get() const
{
if(m_typeIndex == std::type_index(typeid(T)))
return *reinterpret_cast<const T*>(&m_data);
else if(m_typeIndex == std::type_index(typeid(RecursiveWrapper<T>)))
return (*reinterpret_cast<const RecursiveWrapper<T>*>(&m_data)).Get();
else
throw std::bad_cast();
}

template<typename T>
T& Get()
{
if(m_typeIndex == std::type_index(typeid(T)))
return *reinterpret_cast<T*>(&m_data);
else if(m_typeIndex == std::type_index(typeid(RecursiveWrapper<T>)))
return (*reinterpret_cast<RecursiveWrapper<T>*>(&m_data)).Get();
else
throw std::bad_cast();
}

~Variant()
{
HelperType::Destroy(m_typeIndex,&m_data);
}

private:

using DataType = typename std::aligned_union<1,Ts...>::type;
using HelperType = VariantHelper<Variant<Ts...>,Ts...>;

static inline std::type_index InvalidType()
{
return std::type_index(typeid(void));
}

std::type_index m_typeIndex;
DataType m_data;
};

template<typename T>
class RecursiveWrapper
{
public:
RecursiveWrapper() {}
~RecursiveWrapper() { }

RecursiveWrapper(const T& t) : m_data(std::make_unique<T>(t)) {}
RecursiveWrapper(T&& t) : m_data(std::make_unique<T>(std::move(t))) {}
RecursiveWrapper& operator=(T& rhs)
{
m_data = std::make_unique<T>(rhs);
return *this;
}

RecursiveWrapper(const RecursiveWrapper& r) : m_data(std::make_unique<T>(r.Get())) {}
RecursiveWrapper(RecursiveWrapper&& r) : m_data(std::move(r.m_data)) {}
RecursiveWrapper& operator=(RecursiveWrapper rhs)
{
std::swap(*this,rhs);
return *this;
}

operator T() const { return *m_data; }

T& Get() const { return *m_data; }

private:
std::unique_ptr<T> m_data;
};


3a35e7  No.26842

If you truly are expert about opengl, please tell me how to use that shit.

I checked opengl, glut, free glut, glfw, glex and all of them but the vanilla one have problem running on every ide known to man. Plus every installation guide refers to an old procedure no longer used.

Do i really need to learn vim and manually use the terminal to use it? Or am I just retarded and there is some hidden package that makes everything work?


3a35e7  No.26845

>>26842

I take it you're on Linux? Install every opengl related library.

You need a few things for open gl. A window, and an opengl context are first. Then you need a wrangling library. The wrangling library gets you the pointers into the opengl lib where the functions you want are.

GLFW handles window and context creation. Something like GLEW handles the wrangling.

There are alternatives to the above libraries. I use SDL2 for windows and context and another lib I forget the name of (on the phone, so cant check right now) for wrangling. But GLFW and GLEW are like the starters thing.

After you've linked these to your project, they're ready to be used. There's a trillion examples and tutorials online.

Learnopengl.com is in my opinion the best. A lot of tutorials out there are old and teach you old deprecated things, that website teaches only new things.

That's about all I can say unless you have a more specific question?


3a35e7  No.26861

>>26859

Yeah, nodev, I will review your code.

I don't go on the irc.

Do you have a bitbucket or github or something? You can just share a link with me. Or if you want to keep your shit secret, I can request access or whatever on bitbucket and then you can let me see.

(8ch is broken)


3a35e7  No.26862

>>26861

sick

I have it on github, publicly, but I'd rather not post that here.

I can post my steam if you have one.


3a35e7  No.26864

>>26862

Fair enough. Post your id and when I get home ill friend you.


3a35e7  No.26872

invite sent


3a35e7  No.27020

>>26830

Know anything about runtime C++ scripting?


3a35e7  No.27031

>>27020

OP here. Not much, half of the point of C++ is native run.

But, if you mean like a JIT compiler? Yeah I can help you with that. I've also written my own scripting language and runtime for my game engine.

You might want to look at the now open source doom 3 / idtech engine. I believe they used a JIT compiler for C-like scripting.


3a35e7  No.27052

>>27031

https://github.com/RuntimeCompiledCPlusPlus/RuntimeCompiledCPlusPlus/wiki/How-it-works

is a resource i've found.

Unreal is switching to a less optimized version of this for C++ hot loading.

I've been trying to figure out how to implement it without being as hacky/platform dependent to no avail


3a35e7  No.27060

>>27052

Not too hard. Just implement a compiler in your game...


3a35e7  No.27119

>>26830

I just need one question answered, for now.

Multitexturing.

What about variables there? What if one mesh has 2 textures, another has 1, another has 4?

How to deal with the shaders? A shader for each use case?


3a35e7  No.27122

>>26845

I recommend glLoadGen or the "OpenGL Loader Generator" as a wrangling lib. Generate once, just save in your git or infinitely inferior versioning system of your project and you're good to go.

PROTIP: OpenGL isn't hard, just learn a little bit of math.

The three things to know when dealing with OpenGL:

>rewriting equations (and knowing how to rewrite a god damn quadratic formula)

>matrix/vector operations

>highschool trig

The rest you can all google and find a reasonable hack for.

Also: [blah blah, they teach math wrong, blah blah blah]

tl;dr: go read Lockhart's Lament

https://www.maa.org/external_archive/devlin/LockhartsLament.pdf


3a35e7  No.27140

>Sepples thread

>including OGL/GLSL

>woman in OP

Yeah, no thx


3a35e7  No.27146

>>27060

Quest where you must find Gnu the Gnu and ask him for the use of his compiler.


3a35e7  No.27154

I'm completely new to programming. I read about ncurse earlier but realized that it's completely different from your expertise. Does C++ work in Windows, and are there any libraries that are similar to ncurse that I can use?


3a35e7  No.27172

>>27154

No C++ only works on linux thats why there are almost no games for windows.


3a35e7  No.27196

>posts a female in OP

>claims to be able to 'help' with 'coding'

Lol no


3a35e7  No.27971

>>26830

Wait wtf is the purpose of this Recursive Variant?

I'm trying to read the code but it's making my eyes bleed almost as badly as STL implementation.

Whats the relation to boost::variant?

Why don't you have any comments whatsoever?

This is certainly not self-documenting.


367724  No.32271

>>27154

https://en.wikipedia.org/wiki/PDCurses

>>27172

I assume he's asking if curses/ncurses only works on windows.


367724  No.32272

>>32271

*only works on linux




[Return][Go to top][Catalog][Nerve Center][Cancer][Post a Reply]
Delete Post [ ]
[]
[ / / / / / / / / / / / / / ] [ dir / 27chan / anita / cop / flutter / lewd / rmart / tulpa / vichan ]