Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

358 Neutral

About wolverine

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. wolverine

    Linear interpolation of cube corner vals inside cube

    Hi. This is a common problem within volume rendering and isosurfacing: given a cube with 8 values at its vertices, what is the value at a point p within the cube. The usual approach is to use trilinear interpolation. There are a lot papers describing this. For example, see the beggining os section 2 of this paper.
  2. wolverine

    generic containers in C

    Quote:Original post by Sneftel Indeed. If the line ends with a backslash, you'll need to put a space after it to keep the line break from being removed. Totally awesome, huh? Pretty much every thread about macros has this happen sooner or later. Yep, it worked :)
  3. wolverine

    generic containers in C

    Quote:Original post by LessBread Run some tests on those macros first. Iirc, there's an error in the generated code. I don't recall exactly where as it's been several years. Check your compiler specs for the command line switch that outputs preprocessor code. Instance those macros in your test file, then output the preprocessor results and review that code to locate the error. Quote:Original post by DevFred Quote:Original post by LessBread Check your compiler specs for the command line switch that outputs preprocessor code. gcc -E I've tried the code and made some changes. The changes were: * due to html, the operator "->" was posted as "-". I've replaced that on the code. * added "#define DEF_SIZE 2" since it was needed by the code (it assumed the value existed). However, it's easy to change the code to eliminate this need. * in the macro-function "int type##_AddElem(type##_Vector *pV, type Data)", I've replaced the first if from "if(pV-len = pV-size)" to "if(pV->len == pV->size)" * in the macro-function "type type##_GetElemAt(type##_Vector *pV, int pos)", I've replaced the if "if(pos = 0 && pos <= pV-len)" to "if(pos >= 0 && pos < pV->len)" Here's the modified code: #include <stdio.h> #include <stdlib.h> /*Macro definitions from http://www.flipcode.com/archives/Faking_Templates_In_C.shtml*/ #define DEF_SIZE 2 #define CREATE_VECTOR_TYPE_H(type) \ typedef struct _##type##_Vector{ \ type *pArray; \ type illegal; \ int size; \ int len; \ } type##_Vector; \ void type##_InitVector(type##_Vector *pV, type illegal); \ void type##_InitVectorEx(type##_Vector *pV, int size, type illegal); \ void type##_ClearVector(type##_Vector *pV); \ void type##_DeleteAll(type##_Vector *pV); \ void type##_EraseVector(type##_Vector *pV); \ int type##_AddElem(type##_Vector *pV, type Data); \ type type##_SetElemAt(type##_Vector *pV, int pos, type data); \ type type##_GetElemAt(type##_Vector *pV, int pos); #define CREATE_VECTOR_TYPE_C(type) \ void type##_InitVector(type##_Vector *pV, type illegal) \ { \ type##_InitVectorEx(pV, DEF_SIZE, illegal); \ } \ void type##_InitVectorEx(type##_Vector *pV, int size, type illegal) \ { \ pV->len = 0; \ pV->illegal = illegal; \ pV->pArray = malloc(sizeof(type) * size); \ pV->size = size; \ } \ void type##_ClearVector(type##_Vector *pV) \ { \ memset(pV->pArray, 0, sizeof(type) * pV->size); \ pV->len = 0; \ } \ void type##_EraseVector(type##_Vector *pV) \ { \ if(pV->pArray != NULL) \ free(pV->pArray); \ pV->len = 0; \ pV->size = 0; \ pV->pArray = NULL; \ } \ int type##_AddElem(type##_Vector *pV, type Data) \ { \ type *pTmp; \ if(pV->len == pV->size) \ { \ pTmp = malloc(sizeof(type) * pV->size * 2); \ if(pTmp == NULL) \ return -1; \ memcpy(pTmp, pV->pArray, sizeof(type) * pV->size); \ free(pV->pArray); \ pV->pArray = pTmp; \ pV->size *= 2; \ } \ pV->pArray[pV->len] = Data; \ return pV->len++; \ } \ type type##_SetElemAt(type##_Vector *pV, int pos, type data) \ { \ type old = pV->illegal; \ if(pos = 0 && pos <= pV->len) \ { \ old = pV->pArray[pos]; \ pV->pArray[pos] = data; \ } \ return old; \ } \ type type##_GetElemAt(type##_Vector *pV, int pos) \ { \ if(pos >= 0 && pos < pV->len) \ return pV->pArray[pos]; \ return pV->illegal; \ } /* this is supposed to go into an h file*/ CREATE_VECTOR_TYPE_H(int) CREATE_VECTOR_TYPE_H(double) /* this is supposed to go into an c file*/ CREATE_VECTOR_TYPE_C(int) CREATE_VECTOR_TYPE_C(double) /*main*/ int main() { // then you use the functions like int_Vector iv; double_Vector dv; int_InitVector(&iv, -1); // -1 is the illegal double_InitVector(&dv, -1.0); // -1 is the illegal int_AddElem(&iv, 10); int_AddElem(&iv, 11); int_AddElem(&iv, 12); /*cool, it grows*/ double_AddElem(&dv, 3.1415); printf("intvector at[%d]=%d [expected 10]\n",0,int_GetElemAt(&iv,0)); printf("intvector at[%d]=%d [expected 11]\n",1,int_GetElemAt(&iv,1)); printf("intvector at[%d]=%d [expected 12]\n",2,int_GetElemAt(&iv,2)); printf("intvector at[%d]=%d [expected -1]\n",3,int_GetElemAt(&iv,3)); printf("doublevector at[%d]=%e [expected 3.1415]\n",0,double_GetElemAt(&dv,0)); printf("doublevector at[%d]=%e [expected -1.0]\n",1,double_GetElemAt(&dv,1)); printf("doublevector at[%d]=%e [expected -1.0]\n",2,double_GetElemAt(&dv,2)); int_EraseVector(&iv); double_EraseVector(&dv); return 0; } I didn't had time to make extensive testing... I'll problably do it in a day or two and say something then. EDIT: ooooooops this code appears as strange here on gamedev... it's because of the macros :( EDIT2.1: Followed Sneftel sugestion and replaces the "\" by "\ ". If you copy and paste the code and try it, it will generate warnings on some compilers because of the space after the slash. Some other compilers, may even generate an error on this. If you have problems, just replace "\ " for "\" [Edited by - wolverine on August 20, 2008 4:16:54 PM]
  4. wolverine

    generic containers in C

    Quote:Original post by LessBread Faking Templates In C wow... Mighty cool :D
  5. wolverine

    generic containers in C

    Quote:Original post by Hodgman Quote:Original post by Gage64 What if I want to use a vector of ints and a vector of floats in the same program? in my example the structures would be named vector_int and vector_float. The vec_init and vec_push_back are overloaded for these two types. Whether we are considering real overload or not, it will not help you here. Both those functions are referring to the same ELEMENT_TYPE. The "user" would have to redefine the same ELEMENT_TYPE for int and for float which would be not so easy to deal with... Aditionally, if the sizes of the types are different, push_back may not work. [added: DevFred answered that first then me :)! he's fast :D ] The approach I've seen most used is the first one Quote:Original post by DevFred a) Implement a vector with element type pointer-to-void and do casting on the client side. Would it be possible to store integers directly as pointer-to-voids? Is (int)((void*)i) guaranteed to be i, assuming sizeof(void*) == sizeof(int)? Or could I only store pointers in such a vector? where you carry a structure for the vector arround in each function. Something in the lines of: typedef struct { int sizeOfEachElement; int maxCapacity; int numberOfElements; void *data; }GenericVector; void genericVector_Init(GenericVector *vector, int maxElems, int sizeOfEachElement) { vector->sizeOfEachElement = sizeOfEachElement; vector->maxCapacity = maxElems; vector->numberOfElements = 0; vector->data = malloc(sizeOfEachElement * maxElems); } int genericVector_PushElement(GenericVector *vector, void *element) { if(vector->numberOfElements >= vector->maxCapacity) { /*Error condition. vector is full.*/ return ERROR_CODE; } else { memcpy(); memcpy(vector->data + vector->numberOfElements, element, vector->sizeOfEachElement); vector->numberOfElements ++; return 0; } } void genericVector_Destroy() { vector->sizeOfEachElement = 0; vector->maxCapacity = 0; vector->numberOfElement = 0; free(vector->data); vector->data = NULL; } int main() { GenericVector intVect, doubleVect, elephantVect; genericVector_Init(&intVect, 10, sizeof(int)); genericVector_Init(&doubleVect, 20, sizeof(double)); genericVector_Init(&elephantVect, 10, sizeof(Elephant)); ... } [Edited by - wolverine on August 20, 2008 6:35:33 AM]
  6. wolverine

    software for exploring/developing ideas

    Quote:Original post by Sneftel Thanks for the links, everyone. VisualMind looked good, but the price was a bit extravagant. Misi's wiki linki led me to FreeMind, which seems great so far. Freemind is cool, it even allowd you to create links to docs in the nodes (which comes in handy for me). My only small complaint is that sometimes it's hard to control the exact display of the graph (for example, having all the child nodes at the left of the parent node). But it is excellent for a free product!
  7. It seems that Carmack's 2008 keynote has just become available on-line: link
  8. wolverine

    Salaries in Holland

    Quote:Original post by Eelco It also depends. If you tailor your living situation to your commute, public transportation can work fine. If you dont pay any heed, you might end up having to do something like bus->train-&>bus, with 50 minutes of pure travel time and 30 of transfer time, even though you live right next to amsterdam. If your house or place of work is near a public transportation hub, thats a big plus. If you are lucky/clever you can go from work to your home in the next city in 15 minutes or so by train. Quote:Original post by WanMaster Within the city it's pretty good, although many prefer to use bikes. The western part of the Netherlands has a high density network of various types of public transport, but the other cities of the country are also well connected. Ok, thank you both. I will look into the public transportations and the wester part of the Netherlands :). txs
  9. wolverine

    Salaries in Holland

    Quote:Original post by Eelco Most figures here are gross, btw. Gross 3000 - net < 2000 sounds plausible for someone in your position id say. So, taxes are high... bummer :(. Looks like that if I really go I will have to do a lot of digging to find a good house/bedroom for a good price. Do public transportations work well? I mean... if you are far from Amsterdam, is it easy to enter the city in public transportations or do you take a lot of time to do it?
  10. wolverine

    Salaries in Holland

    Quote:Original post by PouyaCat Well... Amsterdam is BLOODY EXPENSIVE! Real question is; what is the Amsterdam area? I live about 1 hour away from the city center, and here things are affordable. Mind you, I live nearly on the other side of the country *laughs* Anyway, I'd say, expect 2000 ~ 2500 euro's a month (gross), provided you can do webdevelopment as well. Cost of living? For 700 ~ 1000 a month you can live nicely, depending on your comfort level (thinking about: car, appartment (2 bedroom), good food, and fun) EDIT: addendum: of course, depends on where you live. I spend less than 200 on my appartment. In Amsterdam, expect to pay around 800 to 1000! Thanks for the information... This was the kind of insight I needed. Maybe I can stay near Amsterdam.
  11. wolverine

    Salaries in Holland

    Quote:Original post by speciesUnknown "Personal reasons" hmm? Everybody thinks about permanently moving to Amsterdam at some point in their lives, and renting a cheap apartment in the red light areas. But the vast majority of us don't do it. lol. I can see it now... he codes during the day, he lives on the red light during the night.
  12. wolverine

    Salaries in Holland

    Hi all, due to personal reasons, I'm considering going abroad to Holland. Can anyone help me finding out what's the average salary in Holland for someone with a degree in Computer Science with about 1,5 - 2 years of experience? Also, what's the average cost of everyday life over there (bedroom rent, food, transportation), particularly in the area of Amsterdam? Thxs
  13. wolverine

    rendering techniques

    Hi By reading your post, I get the feeling that you aren't very updated on the subject... I would recomend that you get a serious reference on it (Real-Time Rendering is excellent). Also, Michael Abrash' Graphics Programming Black Book is quite old (*very* old , only discusses software rendering, but is free and *very* interesting) and on the last chapters he discusses several different algorithms that were considered to be used in the Quake engine which you may find interesting [Edited by - wolverine on January 28, 2008 1:30:00 PM]
  14. wolverine


    Quote:Original post by Vanisher Man, gimme a break, I'm new. Ish. I'm not sure where i got SDL from I'll have to check. All i know is that it came in a zip with very poorly written instructions on how to install it on VC++ which didn't help at all because I'm using DEV-C++. Now I feel like a moron. If you follow the link given by rip-off you'll eventually get to this page: Setting up SDL in Dev C++
  15. Quote:Original post by OrangyTang Is there a transcript anywhere out there? I'd rather read some nice, small, text rather than spend ages for a video download. I've found this blog: live blog but it's not a transcript... just a "live blog" of the speech (as such, it doesn't have much extended info). P.S. I've added the Q&A video link at the 1st post.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!