Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by ajm113

  1.     Sounds like you already covered every inch of what needs to be known making a choice. :wink: Not sure why you started this thread to be honest. Unless I missed the point.
  2. I'm going to assume I'm answering my own question and I'm doing wishful thinking, but I would like to hear some opinions. I've been in web development for 3 - 4 years now working with Linux/Unix, Windows almost as a full stack developer. I really enjoy my job and find it secure, however I've always have had my heart set being a C++ developer forever. (Assuming developer is much more achievable then an engineer.)   Can anyone give me some tips or pointers what US states have the largest cpp market, and perhaps giving me some pointers on what to look for and what to use on the resume? Obviously recent C++ projects, but should I include my web development jobs anyway? Should I shoot for a jr. position that pays decently (60k+) or sr. role (less working with code and more working with clients/managers).   Also has anyone had luck landing a job as a cpp developer position with simply programming experience and no college degree? I plan on working to get my CS degree some time in the future.   Sorry if this isn't in the proper area of the forum.   Thanks,   Ajm
  3.   Interesting, can't say I've ever worked at that level, most people I've worked with is 10. Half of them were UI/UE designers.   To answer your question, I suppose it's simply something I'm most comfortable at of doing and knowing low level of things. i.e I would much rather build the server software that runs the website and dealing with worker threads, logging, and learning the HTTP protocol extensively then actually putting together the PHP and HTML that shows up.   I'm definitely noticing that where I live with all the .NET positions cropping up. Perhaps I'm stubborn, and should just pick up a few books on .NET and deal with the current market to adapt. Not to start any flame wars, or no offense to any die hard fans, I just found .NET a very limited platform, which is why I don't bother with it and I do see why companies use it. Something breaks then there is someone else to yell at. ;)   In all honesty, I'm looking for something rewarding in the long run. (health insurance, retirement, salary). Just something a little more stable, where I work I get no benefits, just pay by the hour. Got a few people telling me they get 40k a year and work 50-60 odd hours a week in the game dev world, seems a lot of stress for nothing.   Hate to say it, but I'm kinda leaning towards the self start up idea of opening a online marketing business that will evolve into other areas. Definitely will need a bit of time and money, before that can get rolling. Of course one thing at a time. ;) You can't be a "astronaut, doctor, and president at the same time".
  4. 1. So you're making a difficult decision between the ideal and the practical, you say. Why do you think you can't have both? Go for it already. It pays well and is reasonably secure. 2. Okay, I admit it - I don't know what the difference is. Care to explain? 3. Why do you think you need a large market? What's wrong with the state where you live? You never mentioned games in your post, so although this is a game forum, I assume you're not looking for a game job. 4. You should put all your work experience on your résumé. 5. You should shoot for a position that you'd be good at and also enjoy. 6. Some people have, but that's irrelevant. How old are you? 7. Why not now? 8. I moved it to the right one.     Good point, why wait, basically. Developer would simply be bug fixing, maintaining code, and integrating new features, as an engineer, you would be using engineering principles for software creation. i.e. wide picture of a big project. One way I see it at least. Where I currently live now in Arizona has a very small cpp software market. It's mainly .NET, CPP is very rare and when one position shows up the requirements are pretty high. I want to do simply software at the moment. I've written small game engines using C++ > Lua, SDL/OpenGL, but nothing more then that. Even smaller projects that simply used C++/C? True, I would need to spend a bit of time researching the market. 24, a lot of HR will shoot down an app with no degree, at least my experience anyway. Too many damn bills and things to take care of at this moment. (Fingers crossed to get back in school next year.) Thanks! :)       I could see that, not sure if a place like Portland vs San Diego would have a large difference for cpp programmers. I was planning on starting a business in online marketing and slowly merging to other areas like A/V, and advertising, when things get rolling, but I'm not 100% sure on that yet.   I can see that, put whatever you have pretty much.   I suppose all that would highly depend on where you live, living in AZ housing would be dramatically different then NY, or NJ. If I got a sr. position I would differently want that 100k salary. haha
  5. I'm almost certain those simply cost 10-20 USD in East Asia to produce. haha       Oh Amazon comments...
  6. Hello,   I'm on the search for file mapping library. I know Win32 has a file mapping functionality, but this doesn't help me for the Unux/Linux community and I know I maybe able to write one my own. (Why reinvent the wheel?) But is their a MIT license file mapping library out their thats cross platform? My project granted will be fine with 4GB RAM machines for small scale projects (32bit), maybe 90GB RAM servers(64bit) if we are talking big data, but supposed someone wanted to go the inexpensive route and do clustering with my application. It will need to use the HD (slow) as means to store data for the program (which maybe a lot of read and writes) if we are talking 5GB to 10GB of data required to be stored.   If someone can give tips or point me in the right direction, that would be amazing, thank you!   -Ajm
  7. ajm113

    Memory File Mapping?

    I'm sorry frob,   it's a nice library, but it's not what I'm looking for exactly. (I should have been more specific) I'm looking to basically store records like a RDBM or like MySQL. Where I'll need to constantly require to be able find data, and or write it from small chunks to large chunks in a file/vector array.
  8. I like to look at it this way...   Is time costing someone else money? 1. Plan (Find the best method) 2. Implement. 3. Test 4.Continue.   Time Costing No One Money 1. Implement. 2. Test. 3. Continue. 5. Finish. 6. Optimize
  9. I'm publishing an update for Awesome INI Loader library. The library now has a new license, WTFPL. So now you may use the library for anything you wish. Why I changed it to this is because I believe code shared to the world, should be able to be modified and used by anyone with or without permission. I know some may differ, but I write code because it's fun, and I want to help the smaller guys out. And for anyone who isn't familiar with this library: This library will load, parse, error check, INI files, while giving the programmer full customization easily, leave small memory footprint, easy to port to any platform, and easy to add to any C++ project. The library has extremely small requirements, and will run on most C++ compilers. Great for small and big projects and gets weekly or monthly updates. The library has a few new functions! Telling from the image, error checking and getting the data you want is 2x much simpler and faster now that the library supports these new functions...[code=:0] bool getKeyInt(int &p, const char* group, const char* key); bool getKeyBool(bool &p, const char* group, const char* key); bool getKeyString(char* dstBuffer, const char* group, const char* key); bool getKeyFloat(float &p, const char* group, const char* key); The code is pretty much self explanatory, but I'll give a small run down... The first arguments are the variables or buffers you wish to pass to store the data. Arguments 2 and 3 are the group and key you wish to retrieve. If everything goes well, the functions will return true, and you dont have to check the error function. Otherwise if it does you may need see whats going on. I've also added a little documentation to the error codes in the source code in "awesome_ini.h".
  10. Hello everyone! I would like to introduce my INI library parser. I wrote from scratch and would like to thank the community for their help, writing this library. So whats so good about this library? Lightweight small memory footprint. Easy to modify BSD License Pure C++ mixed with C. (Easy to port) Multiplatform Easy to use error handling system. One pointer does all. Easy to setup with any project. Easy to customize to your project needs. (Want to use "#" for comments? Change separator? Edit one line of code!) Im really looking for some testers and input to make this project better for everyone for any application big and small! Example code:#include "awesome_ini.h"int _tmain(int argc, _TCHAR* argv[]){ awesome_ini* myIni = new awesome_ini("test.ini"); AWESOME_ERROR_CODES r = myIni->getError(); size_t l = myIni->getErrorLine(); if (r == AWESOME_ERROR_NONE) { printf("Loaded ini!\n"); } else { printf("Failed! %i %i\n", r, l); } char value[AWI_MAX_VALUE_NAME_LENGTH]; AWESOME_INI_KEY_TYPE t = myIni->getKey(value, "test", "hello"); printf("Variable Type: %i - Variable Value: %s\n", t, value); getchar(); return 0;} If anyone has any questions or would like to help port this library to other languages let me know! http://sourceforge.net/projects/awesomeiniloader/ Thank you! ajm113
  11. Hello, I'm writing a library using low level C++ methods so my library can easily be built in C. So I'm staying away from C++ standard templates. So vectors and strings are a bit limit. (Plus I think it's fun to have a bit of a challenge. ;) ). I've mostly been using strings in C++ for ease of use, and I decided to stick with char pointers, but I appear to run into odd problems, of which I cant explain.. I'll give a example. //Issue One char buffer[MAX_LENGTH]; sprintf_s(buffer, MAX_LENGTH, "Hello World!") const char* bufferP = doLogic(buffer); //bufferP = "Goodbye World!" after doLogic //Some random function in my class that has nothing to do with bufferP at all. doMoreMath(); //Wut? Now bufferP equals random garbage data? //bufferP = "/////////tx///" I know this problem can be fixed doing this: const char* bufferP = doLogin(); char buffer_a[MAX_NAME_LENGTH]; memset(buffer_a, 0, MAX_NAME_LENGTH); strncpy(buffer_a, bufferP, strlen(bufferP)); But why does this happen? This issue never seems to happen on any other pointers I've created, like objects. Is it necessary I do everything in char arrays? So I don't lose data randomly?   Thank you, Andrew.
  12. Funny enough you said that, I do actually already do something like that.   My process...   1. Get idea.   2. Create console application in MVS.   3. Write base classes that do logic in my "main". (Keeps code clean, and easy to look at, plus I don't cause global pollution.)   4. Test in main. //..Includes, etc... int main(...) { //For debugging.. bool printToScreen = true; myClass *myPtr = new myClass("Do something cool!", printToScreen); myPtr->explode(); return 0; } 5. Import library / code to larger project.   6. Drink more coffee.
  13. Crank up the warning level of your compiler until it complains about that line. Returning a pointer to something in the stack is almost universally an error, and your compiler should be able to tell you about it. If you are going to do without std::string, I suggest you reimplement it, as something like this: struct String { char *data; unsigned size; unsigned reserved; }; Then write functions to perform all the operations you need on them.     Ah, thats a very good post. If it means a better programmer at the end of the day, then all warnings are errors.   `doLogic' should also take an argument that is the length of `dstBuffer', so it can make sure to not write past the end of the buffer. Notice how `sprint_s' already does that.     Yes, that would be better to use as well for my error handling system if something went wrong so the user's application doesnt crash because of a small memory error.   char subbuff is stack allocated memory, you NEVER return pointers to stack memory, this is because exactly what you are seeing is happening, instead you pass in a buffer that the function should write to(and you should pass in the size of that buffer). The reason why you don't see this with objects is because when you return an object, you are copying the value from the function, so if i do:   struct Foo{ int x; }; Foo Func(void){ Foo p; p.x = 10; return p; } int main(int argc, char **argv){ Foo f = Func(); printf("%d\n", f.x); return 0; } what's happening is that when p is returned from func, the values of p are copied into the values of f, so your copying the values off the stack into another part of the stack that is still valid in the program context(note: this is a very simiplied explanation). however if we do: struct Foo{ int x; }; Foo *Func(void){ Foo p[2]; p[0].x = 10; p[1].x = 12; return p; } int main(int argc, char **argv){ Foo *f = Func(); printf("%d\n", f[0].x); return 0; } this is undefined behavior, and is very likely to crash the program, this is because you are returning a pointer into stack allocated memory that became invalid the moment you returned from Func. in many cases using the data immediately after would technically still work, but it is undefined and very bad to rely on such behavior. one of the correct solutions is to do like so: struct Foo{ int x; }; bool Func(Foo *p, int psize){ if(psize<2) return false; //failed p[0].x = 10; p[1].x = 12; return true; //succeded! } int main(int argc, char **argv){ Foo f[2]; Func(f, 2); // we can pass stack allocated memory into functions, we just should never return such memory! printf("%d\n", f[0].x); return 0; } edit: always try to provide the minimalist working example to demonstrate your problem, you'll get more concise answers that way, then us trying to understand what the hell your doing.     Very well explained, makes sense now. I appreciate your help and everyone elses! And next time I'll be more specific so it's not a guest that code game.
  14. Ah, that would make sense. So I need to make the memory heap then so I can use the variable globally. I didn't think I would need a working example since I thought putting comments of the output would be enough. I really need to get back to the basics again, but at lower level.   @Mark   DoLogic is anything that returns char*. I.E   Example of a substr function I made: char* awesome_ini::aw_subStr(const char* line, size_t start, size_t length) { char subbuff[AWI_MAX_KEY_NAME_LENGTH]; memset(subbuff, 0, AWI_MAX_KEY_NAME_LENGTH); size_t p = 0; for (size_t i = start; i < length+1; i++) { subbuff[p] = line[i]; p++; } return (char*)subbuff; } That also causes the pointer in the example code to go away after a few lines of code. And do math is simply a function that does anything really...   I.E void doMath(void) { //Do some long calculation int x = 5 - 2; printf("%i\n", x); }
  15. *clears throat* http://www.amazon.com/s/ref=sr_nr_p_n_feature_keywords_3?rh=n%3A13447451%2Ck%3Agame+capture%2Cp_n_feature_keywords_three_browse-bin%3A8079887011&keywords=game+capture&ie=UTF8&qid=1410216227&rnid=8079883011   So if we do the math... (Avg program worth per hour 15.00-50.00) So lets use the min a programmer makes to do the math... 8-15hrs (2 days of about 8 hours a day) = Est. 150-250 dollars just to write something your going to use no more then a week.   If you ask me, you may as well buy one of those game recorders those Chinese manufacturing companies are barfing out. and use your time to make a good game. Basically, "if you need to break rules to get to your goal, then maybe your not doing it right."   Cant afford one a game recorder? Then maybe your should be in a job that utilizes your skills with higher pay.
  16. I know this may seem like a very obvious question, but I want to be sure I'm approaching this situation correctly, or if I'm doing it wrong and there is a better picture I'm not simply seeing. I'm designing a GUI system for my game engine, since I just need a few controls and I don't need a fancy GUI library with all the bells and whistles. (Buttons, text, console, edit bar, images) So nothing fancy really. I wanted to know since I want to keep "pages" of the GUI. So if the user clicks "Credits" or "New Game" The UI will show another page with UI controls. Pretty simple stuff. Here is what I have already. #ifndef GUI_MODEL_H #define GUI_MODEL_H #include "Vector.h" enum GUI_STATE { STATE_NULL = 0, STATE_CLICKED, STATE_HOVER, STATE_ACTIVE }; class GUI_Model { public: GUI_Model(void); virtual ~GUI_Model(void); void setPosition(Vector<int> pos); void setSize(Vector<int> size); void setTexture(GLuint texture); void setDraw(bool draw); void enable(bool enable=true); virtual bool pointInside(Vector<int> pos); void setState(GUI_STATE state=STATE_NULL); GUI_STATE getState(void); virtual void draw(void) { return; }; protected: Vector<int> m_position; Vector<int> m_size; bool m_enabled; bool m_draw; GLuint m_texture; GUI_STATE m_state; }; #endif Which can work like this... #ifndef BUTTON_H #define BUTTON_H class Button : public GUI_Model { Button(std::string text); ~Button(void); void draw(void); protected: private: //Custom params. Font, text, etc.. std::string text; } #endif How I would like to see it work in a nutshell... std::vector<std::vector<GUI_Model*>> pages; //New Page pages.push_back(std::vector<GUI_Model*>); size_t current_page = 0; Button* myButton = new Button("Click Me!"); myButton->setSize(Vector<int>(100, 30)); std::vector<std::vector<GUI_Model*>> pages.at(current_page).push_back(myButton); //Check button states handler / OpenGL calls, etc.. size_t num_pages = pages.size(); for(size_t i = 0; i<num_pages; i++) { //etc.... } I plan on using Game Monkey Script to create the UI for everything, so the code has to be very adaptable.
  17. I made a structure for anyone who maybe wondering how to setup a simple GUI system. As long as you know basic C++, some algebra, and English, it's pretty much filling the gaps...   This gui handler simply accepts the created model... #ifndef GUI_HANDLER_H #define GUI_HANDLER_H #include "gui_model.h" class gui_handler { public: gui_handler(void); virtual ~gui_handler(void); size_t newPage(void); bool insert(gui_model* model, size_t index=0); gui_model* poll_event(Vector<int> mouse, int state); void clearAll(void); protected: private: std::vector<std::vector<gui_model*>> m_pages; }; #endif This model simply stores extra params, and data about the control.... #ifndef GUI_MODEL_H #define GUI_MODEL_H #include "../Math/vector.h" enum GUI_MODEL { MODEL_NULL = 0, MODEL_BUTTON, MODEL_TEXT, MODEL_EDIT, MODEL_IMAGE }; enum GUI_STATE { STATE_NULL = 0, STATE_ACTIVE, //Used for edit field... STATE_RIGHT_CLICK_DOWN, STATE_RIGHT_CLICK_UP, STATE_LEFT_CLICK_DOWN, STATE_LEFT_CLICK_UP, STATE_HOVER, STATE_KEY_UP, STATE_KEY_DOWN }; class gui_model { public: gui_model(GUI_MODEL model, std::string title, Vector<int> pos, Vector<int> size, bool draw = true, void* ptr = NULL); virtual ~gui_model(void); void show(bool draw=true); void setTitle(std::string title); void enable(bool enable = true); void setPosition(Vector<int> pos); void setSize(Vector<int> pos); void setTexture(GLuint tex=0); void setState(GUI_STATE=STATE_NULL); void setPtr(void* ptr); virtual void draw(void) { }; virtual bool isInside(Vector<int> pos); GUI_MODEL getModel(void); GUI_STATE getState(void); bool isEnabled(void); Vector<int> getPosition(void); Vector<int> getSize(void); void* getPtr(void); protected: private: GUI_MODEL m_model; GUI_STATE m_state; std::string m_title; Vector<int> m_position; Vector<int> m_size; bool m_draw; bool m_enabled; GLuint m_texture; void* m_ptr; }; #endif
  18.   If that's the goal, then why code your own API? You can use CreateWindow(...) for various buttons and boxes and store the HWNDs in a vector. Specify BS_OWNERDRAW if you want to customize the look. Store an instance pointer and use GetWindowLongPtr to get the style and userdata for custom dispatching.     +1   Trying to make your own GUI API is going to be so much work that you're not actually going to get to use it.  Trying to handle the low-level operating system events while still keeping an abstraction for high-level code is not easy.  You would really be better off learning an existing API.       Well I guest that would depend on how complex we are talking about. If anything really the only things I would need to worry about IO is just the buttons. Everything else, images, text, are just for UI and not UE. Now if I was using scrollbars, dropdowns, the kitchen sink. I agree with you 100% and use CEGUI and save my self the trouble. In this case since I really just want buttons and nothing more for input. I dont think it's going to be that difficult. But thats just my point of view of the task. ;)   I just dont see why time and trouble needs to be spent using a library. (Easy to install at times vs writing your own code yes), but then having to ensure that lib works on targeted platforms, and licensing isnt going to be a issue down the road, specially if you just need to use 2% of the features the library includes.     If that's the goal, then why code your own API? You can use CreateWindow(...) for various buttons and boxes and store the HWNDs in a vector. Specify BS_OWNERDRAW if you want to customize the look. Store an instance pointer and use GetWindowLongPtr to get the style and userdata for custom dispatching.     I guest it wouldn't be a issue to make a base class that has everything needed, and just use uint to store params, now that you say it like that.
  19.   The question is how can I write a vector or array to store mutliple class types that share the same sub class, while being able to store the data in the base class.   I.E class Base { public: Vector<int> size; Vector<int> position; }; class button : public Base { public: std::string msg; button_struct button_data; }; class image: public Base { std::string imagePath; } //Some init funcs... button m_button = new button("Click this"); image m_image = new image("image.png"); someVector.push_back(m_button); someVector.push_back(m_image); I was thinking of simply using how Win32 does things, and use the same architecture. (One class does all) and simple have a int that I can declare as what sort of object it is.       I'll take a look around, thank you for the post.
  20. It's a work night and I'm in the mood for some opinions then help with a project. If anything I had a certain library I would like to build down the road, and I want to use Java as my platform anyways for a bigger project, and would like to use Java as a means of prototyping/debugging/testing to make mass data management a breeze for a upcoming project and hope it can replace sql lite.   We all know C++/C are great at building portable, slim, good performance applications for your environment, but have many traps for young players wanting to release their applications on a any day machine, which is why I notice a lot of us use functional programming to test out something before spending hours converting that code to C/C++. Just like the big boys, Google. ;) Of course at the end of the day, it's all about what gets the job done. Even if you use Erlang to do heavy number crunching, and you manage to make it out perform it's self with some hacking.   Anyways my question is to everyone is. What is your prototype language? Did you pick it because it's what your most comfortable with? Or do you go out of your comfort zone to learn something new because the language supported your needs for prototyping. Or is it basically, I have no prototype language, you use what language you plan to launch with?
  21. I been meaning to give Go a try I'm wondering how well Golang compares to Java with socket programming.
  22. I've been looking hard for a legit software engineer job. And I think I'm on the right track, but for the most part I've had no luck getting the job I want. For the most part it appears Arizona is deep into Java/.NET. I know how to write in Java and C#. I've been programming for 5 years of my life as a open source contributor and made one close source project I released for sale. I should mention I have a certificate in Object Oriented Programming. The company Stepfy, lets me use Java heavily to write web spiders to collect data. Stepfy, is a start up. So far the stock certificate is worthless, till the company starts going public in the next few months.   I'm hopping if I post my resume here I can get some better ideas how to write my resume and maybe how to job search. A lot of job agencies appear to be really iffy about my experience w/ out a bachelors in CS or 1 year of real experience. Any tips or ways to appear more attractive to employers?   [EDIT] I doubt this is in the right area, since I meant more Software Engineering.
  23. ajm113

    How Is My Resume?

    You make a very good point. I honestly didn't add much is because I felt like I would be over qualified, but with my lack of schooling, I should use my projects as an advantage now that you say that.     I was thinking this formatting of my experience would be good... Project Name ..... [date] X & Y Programmer Makes X equal Y...   Thank you so much, it makes more sense now, looking at the other perspective. Now I just have to call some of the staffing agencies with my new resume. ;) Maybe they will give me a shot. I was thinking of maybe putting some cash on the side for another certification for kicks, but I'm not sure how good that would actually do on a resume.
  24. Hello everyone!   I think this maybe more related to perhaps more of how I calculated my normals, then a OpenGL issue. But I assume the best place to ask would be OpenGL forum encase if it's the way I told OpenGL to handle my normals.   Anyways I dont think my normals are calculated correctly, because I'm throwing in a rotating cube into my scene using triangles, and it appears only some triangles seem to light up correctly. Otherwise most of them are simply just black. Btw my scene is drawn clockwise if that makes a difference... And I'm using glNormalPointer, glVertexPointer, etc.. to draw everything and to make my OpenGL calls optimized as much as I can. ;)     Cube class constructor: Not really important I suspect since all this does is put together the cube and does nothing with the normals, but just encase... Cube[0] = m_pos.m_X-m_size.m_X; Cube[1] = m_pos.m_Y+m_size.m_Y; Cube[2] = m_pos.m_Z+m_size.m_Z; //Vector2 Cube[3] = m_pos.m_X+m_size.m_X; Cube[4] = m_pos.m_Y+m_size.m_Y; Cube[5] = m_pos.m_Z+m_size.m_Z; //Vector3 Cube[6] = m_pos.m_X-m_size.m_X; Cube[7] = m_pos.m_Y-m_size.m_Y; Cube[8] = m_pos.m_Z+m_size.m_Z; //Second triangle... //Vector 1 Cube[9] = m_pos.m_X-m_size.m_X; Cube[10] = m_pos.m_Y-m_size.m_Y; Cube[11] = m_pos.m_Z+m_size.m_Z; //Vector2 Cube[12] = m_pos.m_X+m_size.m_X; Cube[13] = m_pos.m_Y+m_size.m_Y; Cube[14] = m_pos.m_Z+m_size.m_Z; //Vector3 Cube[15] = m_pos.m_X+m_size.m_X; Cube[16] = m_pos.m_Y-m_size.m_Y; Cube[17] = m_pos.m_Z+m_size.m_Z; //BACK face... //First triangle. //Vector 1 Cube[18] = m_pos.m_X+m_size.m_X; Cube[19] = m_pos.m_Y+m_size.m_Y; Cube[20] = m_pos.m_Z-m_size.m_Z; //Vector2 Cube[21] = m_pos.m_X-m_size.m_X; Cube[22] = m_pos.m_Y+m_size.m_Y; Cube[23] = m_pos.m_Z-m_size.m_Z; //Vector3 Cube[24] = m_pos.m_X+m_size.m_X; Cube[25] = m_pos.m_Y-m_size.m_Y; Cube[26] = m_pos.m_Z-m_size.m_Z; //Second triangle... //Vector 1 Cube[27] = m_pos.m_X-m_size.m_X; Cube[28] = m_pos.m_Y+m_size.m_Y; Cube[29] = m_pos.m_Z-m_size.m_Z; //Vector2 Cube[30] = m_pos.m_X-m_size.m_X; Cube[31] = m_pos.m_Y-m_size.m_Y; Cube[32] = m_pos.m_Z-m_size.m_Z; //Vector3 Cube[33] = m_pos.m_X+m_size.m_X; Cube[34] = m_pos.m_Y-m_size.m_Y; Cube[35] = m_pos.m_Z-m_size.m_Z; //LEFT face... //First triangle. //Vector 1 Cube[36] = m_pos.m_X+m_size.m_X; Cube[37] = m_pos.m_Y-m_size.m_Y; Cube[38] = m_pos.m_Z-m_size.m_Z; //Vector2 Cube[39] = m_pos.m_X+m_size.m_X; Cube[40] = m_pos.m_Y-m_size.m_Y; Cube[41] = m_pos.m_Z+m_size.m_Z; //Vector3 Cube[42] = m_pos.m_X+m_size.m_X; Cube[43] = m_pos.m_Y+m_size.m_Y; Cube[44] = m_pos.m_Z+m_size.m_Z; //Second triangle... //Vector 1 Cube[45] = m_pos.m_X+m_size.m_X; Cube[46] = m_pos.m_Y+m_size.m_Y; Cube[47] = m_pos.m_Z-m_size.m_Z; //Vector2 Cube[48] = m_pos.m_X+m_size.m_X; Cube[49] = m_pos.m_Y-m_size.m_Y; Cube[50] = m_pos.m_Z-m_size.m_Z; //Vector3 Cube[51] = m_pos.m_X+m_size.m_X; Cube[52] = m_pos.m_Y+m_size.m_Y; Cube[53] = m_pos.m_Z+m_size.m_Z; //RIGHT face... //First triangle. //Vector 1 Cube[54] = m_pos.m_X-m_size.m_X; Cube[55] = m_pos.m_Y-m_size.m_Y; Cube[56] = m_pos.m_Z-m_size.m_Z; //Vector2 Cube[57] = m_pos.m_X-m_size.m_X; Cube[58] = m_pos.m_Y+m_size.m_Y; Cube[59] = m_pos.m_Z-m_size.m_Z; //Vector3 Cube[60] = m_pos.m_X-m_size.m_X; Cube[61] = m_pos.m_Y-m_size.m_Y; Cube[62] = m_pos.m_Z+m_size.m_Z; //Second triangle... //Vector 1 Cube[63] = m_pos.m_X-m_size.m_X; Cube[64] = m_pos.m_Y+m_size.m_Y; Cube[65] = m_pos.m_Z-m_size.m_Z; //Vector2 Cube[66] = m_pos.m_X-m_size.m_X; Cube[67] = m_pos.m_Y+m_size.m_Y; Cube[68] = m_pos.m_Z+m_size.m_Z; //Vector3 Cube[69] = m_pos.m_X-m_size.m_X; Cube[70] = m_pos.m_Y-m_size.m_Y; Cube[71] = m_pos.m_Z+m_size.m_Z; //TOP face... //First triangle. //Vector 1 Cube[72] = m_pos.m_X+m_size.m_X; Cube[73] = m_pos.m_Y+m_size.m_Y; Cube[74] = m_pos.m_Z+m_size.m_Z; //Vector2 Cube[75] = m_pos.m_X-m_size.m_X; Cube[76] = m_pos.m_Y+m_size.m_Y; Cube[77] = m_pos.m_Z+m_size.m_Z; //Vector3 Cube[78] = m_pos.m_X+m_size.m_X; Cube[79] = m_pos.m_Y+m_size.m_Y; Cube[80] = m_pos.m_Z-m_size.m_Z; //Second triangle... //Vector 1 Cube[81] = m_pos.m_X-m_size.m_X; Cube[82] = m_pos.m_Y+m_size.m_Y; Cube[83] = m_pos.m_Z+m_size.m_Z; //Vector2 Cube[84] = m_pos.m_X-m_size.m_X; Cube[85] = m_pos.m_Y+m_size.m_Y; Cube[86] = m_pos.m_Z-m_size.m_Z; //Vector3 Cube[87] = m_pos.m_X+m_size.m_X; Cube[88] = m_pos.m_Y+m_size.m_Y; Cube[89] = m_pos.m_Z-m_size.m_Z; //BOTTOM face... //First triangle. //Vector 1 Cube[90] = m_pos.m_X-m_size.m_X; Cube[91] = m_pos.m_Y-m_size.m_Y; Cube[92] = m_pos.m_Z+m_size.m_Z; //Vector2 Cube[93] = m_pos.m_X+m_size.m_X; Cube[94] = m_pos.m_Y-m_size.m_Y; Cube[95] = m_pos.m_Z+m_size.m_Z; //Vector3 Cube[96] = m_pos.m_X+m_size.m_X; Cube[97] = m_pos.m_Y-m_size.m_Y; Cube[98] = m_pos.m_Z-m_size.m_Z; //Second triangle... //Vector 1 Cube[99] = m_pos.m_X-m_size.m_X; Cube[100] = m_pos.m_Y-m_size.m_Y; Cube[101] = m_pos.m_Z+m_size.m_Z; //Vector2 Cube[102] = m_pos.m_X+m_size.m_X; Cube[103] = m_pos.m_Y-m_size.m_Y; Cube[104] = m_pos.m_Z-m_size.m_Z; //Vector3 Cube[105] = m_pos.m_X-m_size.m_X; Cube[106] = m_pos.m_Y-m_size.m_Y; Cube[107] = m_pos.m_Z-m_size.m_Z; normals = GLShortcuts::calculateNormal(Cube, 12); calculateNormal... I know it's a tiny bit messy, but it's partly because of debugging reasons... float* GLShortcuts::calculateNormal(float vec[], size_t triangles) { float* normals = new float[triangles*3]; size_t normPos = 0; size_t vexPos = 0; for(size_t i = 0; i<triangles; i++) { VECTOR_3D v1 = VECTOR_3D(vec[vexPos], vec[vexPos+1], vec[vexPos+2]); VECTOR_3D v2 = VECTOR_3D(vec[vexPos+3], vec[vexPos+4], vec[vexPos+5]); VECTOR_3D v3 = VECTOR_3D(vec[vexPos+6], vec[vexPos+7], vec[vexPos+8]); vexPos += 9; VECTOR_3D crossVec1 = (v2 - v1); VECTOR_3D crossVec2 = (v3 - v1); VECTOR_3D normal; normal.m_X = crossVec2.m_Y*crossVec1.m_Z - crossVec1.m_Y*crossVec2.m_Z; normal.m_Y = crossVec1.m_X*crossVec2.m_Z - crossVec2.m_X*crossVec1.m_Z; normal.m_Z = crossVec2.m_X*crossVec1.m_Y - crossVec2.m_Y*crossVec1.m_X; normal.Normalize(); normals[normPos+0] = normal.m_X; normals[normPos+1] = normal.m_Y; normals[normPos+2] = normal.m_Z; normPos+=3; } void CubeGL::draw(void) { if(m_texId > 0) { glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); } glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glVertexPointer(3, GL_FLOAT, 0, Cube); glTexCoordPointer(2, GL_FLOAT, 0, UV_Coords); glNormalPointer(GL_FLOAT, 0, normals); glDrawArrays(GL_TRIANGLES, 0, 36); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); if(m_texId > 0) { glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); } } And thats the draw code. Assuming if I'm being a tard with how I'm calling the normals.
  25. ajm113

    Trouble Calculating Normals

    Well it very well just could be how I'm using glNormalPointer, because I used the down and dirty method to draw a plane with two triangles, and it looked perfectly fine! D: FAIL! If someone can tell me why this could be that would be nice!   I.E How it should look to OpenGL. //Draw plane... glBegin(GL_TRIANGLES); glNormal3f(normals[0], normals[1], normals[2]); //Draw triangle... glVertex3f(...); glNormal3f(normals[3], normals[4], normals[5]); //Draw another triangle... glVertex3f(...); glEnd();
  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!