[QUOTE=Dienes;45377730]No difference at all, except that with the second version you could do[cpp]enum class { // No type name
MODEL, LINE
}type;[/cpp]to have an anonymous type.[/QUOTE]
Right, thanks. Except that wouldn't work right now, because it's a scoped enumerator.
Actually I don't know why it wouldn't work, but it doesn't seem to with enum classes.
[QUOTE=WTF Nuke;45377759]Right, thanks. Except that wouldn't work right now, because it's a scoped enumerator.
Actually I don't know why it wouldn't work, but it doesn't seem to with enum classes.[/QUOTE]
Ah, true, that only works with regular enums. I guess because with scoped ones you are required to have Type:: in front of the values, which obviously wouldn't work then.
is it better to just create variables and strings of the sort all at the top in the beginning of int main? or could i just create the variable or string, right before i need to use it?
<snipped>
[QUOTE=confinedUser;45381374]is it better to just create variables and strings of the sort all at the top in the beginning of int main? or could i just create the variable or string, right before i need to use it?[/QUOTE]
Declare and initialize when you need it. It makes it more readable because you can see where a variable is used. Declaring them only at the top was an old C thing, but any compiler now supports declaring variables anywhere.
[QUOTE=Felheart;45381588]Changed phase 3 of the generation procedure.
In this image you can see the "raw seed output" (just grid-spamming probes)
with only the 3rd filter to remove probes.
Its pretty complicated but basically it aims to keep probes in regions where lighting changes...
For debugging purposes I'm only generating nodes on the ground so the connections look pretty strange.
- snip -
Looks like it's going to become pretty usable soon :)
And by 'usable' I mean no more human correction required of course![/QUOTE]
You obviously don't need help with this so i'll assume you wanted to post this in WAYWO not WDYNHW?
[QUOTE=cartman300;45381868]You obviously don't need help with this so i'll assume you wanted to post this in WAYWO not WDYNHW?[/QUOTE]
Oh god you're right! I don't think I can remove my post can I? I'll "snip" it out.
so i've been following the tutorials at [URL="http://open.gl"]open.gl[/URL] and a [URL="https://www.youtube.com/watch?v=ss3AnSxJ2X8&list=PLEETnX-uPtBXP_B2yupUKlflXBznWIlL5"]few[/URL] [URL="https://www.youtube.com/user/BSVino/playlists"]other[/URL] [URL="http://www.gametutorials.com/tutorials/opengl-tutorials/"]websites[/URL], trying to get OpenGL to render an .obj mesh. so far it's been fine, but i've run into a problem:
this is [URL="https://gist.github.com/MGinshe/693a9af707d344992645"]sphere.obj[/URL]
[IMG]http://i.gyazo.com/1d9df6ef608558c816f857e892b6b643.gif[/IMG]
[URL="https://gist.github.com/MGinshe/26d1bf0391aba97c6578"]cube.obj[/URL]
[IMG]http://i.gyazo.com/ad7e310c8289e407a632c4fefb1af209.png[/IMG]
and the [URL="http://graphics.stanford.edu/~mdfisher/Data/Meshes/bunny.obj"]stanford bunny[/URL]...
[IMG]http://i.gyazo.com/3d1bacdf609706e020d2bd81f3b8bb79.gif[/IMG]
it looks like the vertices/indices are getting mixed up, but i've verified that i'm sending glBufferData exactly what my .obj file has. i'm completely lost. i've uploaded everything to git if anyone wants to check it out.
[URL="https://github.com/MGinshe/OBJViewer"]github repo[/URL]
[b]edit[/b]
turns out i was only reading the first character from the list of indices..
[IMG]http://i.gyazo.com/2e6568ea87ae3e369b8a5b9bc6a59dcd.png[/IMG]
I'm binding Lua into my game, and I've just got my first object working - the in-game console. So now I can call "Console.clear()" and it will clear the input history - great.
I just tried running "Console = nil" as a test, and now I can't use the clear function until I reload the game.
Is there a way I can stop Lua from assigning nil to my Console?
[editline]15th July 2014[/editline]
I've looked up potential metamethods I can give to the Console metatable but there's none for assignment (except for table indices). I guess another solution would be polling it every so often in C++ and reassigning it if need be but that's a massive hack.
I want to learn C# and have access to os x, windows and arch but I want to use OS X
what's my hope of developing with c# on os x; can i easily develop with C# without XAML and .NET
Mono. It doesn't support WPF, and thus no XAML.
[url]http://www.mono-project.com/Main_Page[/url]
if I wanted to make a sprite walk towards the player character, Currently all I would have to do is something like...
Chaser.moveSpriteX((Player.x-Chaser.x)/(ABS(Player.x-chaser.X)));
whereas player is the thing being chaser and the chased is the one doing the chasing. The same function could be done for the Y value.
The problem is this will always make the chaser walk at a 45 degree angle until either the X or Y difference is 0 in which case it will simply walk in a straight line until it reaches the player. I want to be able to do a sort of slope function like "S = (player.x-chaser.x)/(player.y-object.y)" and figure out how to use the slope to say that it should move on the X axis "S" more times than it moves on the Y axis. Any ideas?
Trying to make sure I understand VAO's and VBO's. My non-confident understanding is that VAO's organize the set of relevant VBO's pertaining to a mesh, and you create a unique VAO for each unique model you want to render in your scene?
So if I wanted to render 2+ identical trees and 2+ identical rocks in a scene:
Before game loop, create a VAO for the tree model, and create and populate the relevant VBO's. Do the same process for the rock model. Two VAO's total.
When drawing multiple objects (whether I'm drawing 2 of each object or 10000+) I refer to these VAO's.
Let me know if this is totally wrong or makes too many assumptions: I create a new VAO for every unique mesh rendered in my scene, and that VAO doesn't really care if I'm drawing just one or many.
[QUOTE=mechanarchy;45386932]I'm binding Lua into my game, and I've just got my first object working - the in-game console. So now I can call "Console.clear()" and it will clear the input history - great.
I just tried running "Console = nil" as a test, and now I can't use the clear function until I reload the game.
Is there a way I can stop Lua from assigning nil to my Console?
[editline]15th July 2014[/editline]
I've looked up potential metamethods I can give to the Console metatable but there's none for assignment (except for table indices). I guess another solution would be polling it every so often in C++ and reassigning it if need be but that's a massive hack.[/QUOTE]
In the metatable of Console, put:
[code]
__index = table_containing_methods -- what Console contains is irrelevant
__newindex = function() end -- Can't add members to Console to override methods
[/code]
[editline]14th July 2014[/editline]
And, obviously, table_containing_methods should contain the Console methods such as clear()
[QUOTE=esalaka;45389047]In the metatable of Console, put:
[code]
__index = table_containing_methods -- what Console contains is irrelevant
__newindex = function() end -- Can't add members to Console to override methods
[/code]
[editline]14th July 2014[/editline]
And, obviously, table_containing_methods should contain the Console methods such as clear()[/QUOTE]
you might still run into problems with this. for one, you can still do "Console = nil", because that metatable hack only locks [i]members[/i] of the "Console" table, and not the table itsself. and second, if any of your methods (like clear()) are modifying "Console", they'll also fail because __newindex doesn't actually set or change anything.
you could do some _G metatable hackery to fix it, but people will probably disapprove of that :P
[QUOTE=MGinshe;45392432]you might still run into problems with this. for one, you can still do "Console = nil", because that metatable hack only locks [i]members[/i] of the "Console" table, and not the table itsself. and second, if any of your methods (like clear()) are modifying "Console", they'll also fail because __newindex doesn't actually set or change anything.
you could do some _G metatable hackery to fix it, but people will probably disapprove of that :P[/QUOTE]
Oh, right - damn.
On the other hand, preventing people from doing stupid shit like setting important tables to nil is sort of pointless to prevent - the only reason to do that would be to prevent the use of Console and as such hinder your [I]own[/I] work.
I've never seen anyone do that on purpose, really.
[editline]15th July 2014[/editline]
And _G metatable hackery could be simply bypassed by setting _G another metatable...
[QUOTE=Socram;45389025]Trying to make sure I understand VAO's and VBO's. My non-confident understanding is that VAO's organize the set of relevant VBO's pertaining to a mesh, and you create a unique VAO for each unique model you want to render in your scene?
So if I wanted to render 2+ identical trees and 2+ identical rocks in a scene:
Before game loop, create a VAO for the tree model, and create and populate the relevant VBO's. Do the same process for the rock model. Two VAO's total.
When drawing multiple objects (whether I'm drawing 2 of each object or 10000+) I refer to these VAO's.
Let me know if this is totally wrong or makes too many assumptions: I create a new VAO for every unique mesh rendered in my scene, and that VAO doesn't really care if I'm drawing just one or many.[/QUOTE]
this is how i understood it too, but some of the videos i've watch make me think i might be wrong. i think VAO's relate more to the shader/attribute locations than to meshes.. but, from what i've read, they need to be bound before every glBufferData call, which completely does not make sense to me.
some clarification on this would be awesome
[editline]15th July 2014[/editline]
[QUOTE=esalaka;45392460]Oh, right - damn.
On the other hand, preventing people from doing stupid shit like setting important tables to nil is sort of pointless to prevent - the only reason to do that would be to prevent the use of Console and as such hinder your [I]own[/I] work.
I've never seen anyone do that on purpose, really.
[editline]15th July 2014[/editline]
And _G metatable hackery could be simply bypassed by setting _G another metatable...[/QUOTE]
you could maybe override the setmetatable method. i think they might also be a metamethod to stop people overriding a metatable.
but yeah i agree, it's kinda pointless in lua
[editline]15th July 2014[/editline]
[QUOTE=mechanarchy;45386932]I'm binding Lua into my game, and I've just got my first object working - the in-game console. So now I can call "Console.clear()" and it will clear the input history - great.
I just tried running "Console = nil" as a test, and now I can't use the clear function until I reload the game.
Is there a way I can stop Lua from assigning nil to my Console?
[editline]15th July 2014[/editline]
I've looked up potential metamethods I can give to the Console metatable but there's none for assignment (except for table indices). I guess another solution would be polling it every so often in C++ and reassigning it if need be but that's a massive hack.[/QUOTE]
you could try converting the Console to userdata. afaik userdata can't be modified from the lua side
For VAOs: [url]http://stackoverflow.com/questions/8923174/opengl-vao-best-practices[/url]
[editline]14th July 2014[/editline]
Also this: [url]http://stackoverflow.com/questions/18485381/opengl-how-many-vaos[/url]
Can anyone see what I'm doing wrong here?
I'm trying to make a linked list in C++ using templates
[code]
//DCLinkedList.h
struct DLNode{
DLNode* next;
DLNode* last;
void* data;
};
template <class T>
class DCLinkedList{
public:
void insertFront(void* data);
void insertEnd(void* data);
T* removeFront();
T* removeEnd();
DCLinkedList();
~DCLinkedList();
bool isEmpty();
protected:
DLNode head;
void link(DLNode* n1, DLNode* n2);
};
//DCLinkedList.cpp
#include<stdlib.h>
#include "DCLinkedList.h"
template<class T>
DCLinkedList<T>::DCLinkedList(){
link(&head,&head);
head.data = NULL;
}
//other functions below
//Program.cpp
#include"DCLinkedList.h"
int main(){
DCLinkedList<int> list;
}
[/code]
The compiler says the constructor and any other function from this class I try to call are unresolved external symbols.
You have to fully define templated functions in headers, no .cpp allowed.
A common workaround is to have a secondary include in the header that holds the definitions themselves. I believe GCC does this for a lot of the standard library. GLM also does this, as it is a header-only library.
Is it possible to implement psuedo generics in C? e.g. maybe I would want to implement a vector with a generic type.
[editline]15th July 2014[/editline]
I mean it doesn't take a lot to implement one for each type but it's a bit messy. I guess I should expect that with C.
anyone care to explain why this is not working like it should? i mean in some cases it does but in this case shown below does not count words, or even tell me what the repeated words are. i've been reading programming principles and practice using c++ this was one of it's code snippets i decided to toss it into the compiler and check it out for myself. To my surprise it doesn't work aswell as i thought it would :v:
[IMG]http://puu.sh/abU7v/175478a08e.jpg[/IMG]
here is the code
[code]
#include <iostream>
#include <string>
using namespace std;
int main()
{
string previous = " ";
string current;
int number_of_words=0;
cout << "enter sentence: ";
while(cin>>current)
{
++number_of_words;
if(previous==current)
{
cout << "word number: " << number_of_words << endl;
cout<< "repeated word: "<< current<< "\n";
}
previous=current;
}
return 0;
}
[/code]
[QUOTE=reevezy67;45393543]Is it possible to implement psuedo generics in C? e.g. maybe I would want to implement a vector with a generic type.
[editline]15th July 2014[/editline]
I mean it doesn't take a lot to implement one for each type but it's a bit messy. I guess I should expect that with C.[/QUOTE]
void*
Can't really make it typesafe, so you just trust that the user doesn't fuck it up.
So how would I go about turning this in to a generic vector? How do I calculate the size to allocate from a void pointer?
I could store the type on initialization but I would have to write a conversion for each type then.
[code]
#include "vector.h"
void vec_init(vector* vec)
{
vec->data = (int*)malloc(2 * sizeof(int));
vec->capacity = 2;
vec->size = -1;
}
static void vec_expand(vector* vec)
{
if (vec->size+1 == vec->capacity)
{
vec->capacity *= 2;
vec-> data = (int*)realloc(vec->data, vec->capacity * sizeof(int));
}
}
void vec_add(vector* vec, int i)
{
vec_expand(vec);
vec->data[vec->size+1] = i;
vec->size++;
}
[/code]
You could have it insert and return void*, though this isn't exactly a "vector" as it will just be an array of pointers. Not good for performance.
Or this super kludge:
[cpp]
typedef struct vector {
int size;
int capacity;
char[] data;
int dataSize;
} vector;
//To store ints, pass in sizeof(int) for dataSize
void vec_init(vector* vec, int dataSize)
{
vec->size = 0;
vec->capacity = 2;
vec->dataSize = dataSize;
vec->data = malloc(dataSize * 2);
}
static void vec_expand(vector* vec)
{
if(vec->size+1 == vec->capacity) {
vec->capacity *= 2;
vec->data = realloc(vec->data, vec->capacity * vec->dataSize);
}
}
//Here's the REALLY kludgy bit
void vec_add(vector* vec, void* data)
{
vec_expand(vec);
memcpy(&(vec->data[vec->size+1 * vec->dataSize]), data, vec->dataSize);
vec->size++;
}
//To get stuff out cast vec->data to an array of the appropriate type beforehand
//something like this:
// SomeType foo = ((SomeType[]) vec->data)[SOME_NUMBER];
[/cpp]
This is completely untested and I might have missed a multiplication by dataSize somewhere, don't blame me for any resulting nasal demons, etc.
You could also use macros, which would be somewhat safer.
-snip-
Thanks.
Anyone knows how i can emit to a specific logger using nlog?
I have 2: One outputting to the debug console, and another one outputting to a logservice (logentries.com to be specific). But atm i just need to log to the console, not the service. On option is to comment out the logger in the settings file, but it's a bit cumbersome.
So, long story short, I want to output to log A, but not B and i don't want to comment something out in the config file.
Anyone know how could i make a string calculator in C
something like
[QUOTE]./a.out "3+2*8"
19[/QUOTE]
Thanks.
[QUOTE=ExtReMLapin;45396732]Anyone know how could i make a string calculator in C
something like
Thanks.[/QUOTE]
This might be a good start: [url]https://github.com/jamesgregson/expression_parser[/url]
Google "mathematical parsing" it is a well documented problem.
Thank you.
Sorry, you need to Log In to post a reply to this thread.