Jump to content
  • Advertisement

Vortez

Member
  • Content count

    840
  • Joined

  • Last visited

Community Reputation

2714 Excellent

About Vortez

  • Rank
    Advanced Member

Personal Information

  • Role
    Game Designer
  • Interests
    Programming

Recent Profile Visitors

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

  1. Hi guys, i know this is totally off topic, but that's what the lounge is for, no? I started this thread because i've been arguing with a friend about the van houtte coffee pub, for like for a year or so, so it's time i settle this once and for all. At 0:17, you see Jean Claude Van Damme performing the split, and i know it's him because, well, it's pretty oblivious, but my friend says it's not him. Apparently, jcvd have a small bump on his forehead, and in the pub it's not visible, so it CAN'T be him, he said. So i've wrote this post to settle this question once and for all. What do you think, jcvd or not?
  2. Not sure what you mean by this, since i don't think i need any sharing. That's what im trying to explain, im only using a secondary thread to do the conversion and rendering, so the main thread is not blocked, but im not lauching more than one (secondary) thread at once. ie: Step 1: User add file(s) he want to convert in a listbox Step 2: Main thread launch secondary thread and do it's thing until it finish (the main thread is not blocked) (User interface is disabled until the thread dies) (Secondary thread encode all the files in the list, work well the first time for one or multiple files) Step 3: Just before the thread exit, it post a message to the main thread so the user interface is re-enabled again Then you can go to step 1 again (that's where opengl don't work anymore), or close the application, whatever. Hope this clear things a bit.
  3. Hi guys, im having a little problem fixing a bug in my program since i multi-threaded it. The app is a little video converter i wrote for fun. To help you understand the problem, ill first explain how the program is made. Im using Delphi to do the GUI/Windows part of the code, then im loading a c++ dll for the video conversion. The problem is not related to the video conversion, but with OpenGL only. The code work like this: DWORD WINAPI JobThread(void *params) { for each files { ... _ConvertVideo(input_name, output_name); } } void EXP_FUNC _ConvertVideo(char *input_fname, char *output_fname) { // Note that im re-initializing and cleaning up OpenGL each time this function is called... CGLEngine GLEngine; ... // Initialize OpenGL GLEngine.Initialize(render_wnd); GLEngine.CreateTexture(dst_width, dst_height, 4); // decode the video and render the frames... for each frames { ... GLEngine.UpdateTexture(pY, pU, pV); GLEngine.Render(); } cleanup: GLEngine.DeleteTexture(); GLEngine.Shutdown(); // video cleanup code... } With a single thread, everything work fine. The problem arise when im starting the thread for a second time, nothing get rendered, but the encoding work fine. For example, if i start the thread with 3 files to process, all of them render fine, but if i start the thread again (with the same batch of files or not...), OpenGL fail to render anything. Im pretty sure it has something to do with the rendering context (or maybe the window DC?). Here a snippet of my OpenGL class: bool CGLEngine::Initialize(HWND hWnd) { hDC = GetDC(hWnd); if(!SetupPixelFormatDescriptor(hDC)){ ReleaseDC(hWnd, hDC); return false; } hRC = wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); // more code ... return true; } void CGLEngine::Shutdown() { // some code... if(hRC){wglDeleteContext(hRC);} if(hDC){ReleaseDC(hWnd, hDC);} hDC = hRC = NULL; } The full source code is available here. The most relevant files are: -OpenGL class (header / source) -Main code (header / source) Thx in advance if anyone can help me.
  4. Okay, i fixed the code at bit, i tested the asm part and it work (the first post had a last minute change bug...) Here's the code: #define USE_ASM #define USE_INTEGERS #define USE_MEMCPY ////////////////////////////////////////////////////////////////////////////////////////////// /////// This routine write the value returned by GetProcAddress() at the address p /////////// ////////////////////////////////////////////////////////////////////////////////////////////// bool SetProcAddress(HINSTANCE dll, void *p, char *name) { UINT *x = (UINT*)p; // <--- Used for debugging (if *x change to the value of f in the watch, it mean it work) void *f = GetProcAddress(dll, name); if(!f) return false; #ifdef USE_ASM // This work... _asm { push eax push ebx mov eax, f mov ebx, p mov [ebx], eax // <--- put eax at the address pointed by ebx pop ebx pop eax } #endif #ifdef USE_INTEGERS *x = 0; UINT *x1 = (UINT*)p; UINT *x2 = (UINT*)f; (*x1) = (*x2); // this give the value at address f, so it doesn't work #endif #ifdef USE_MEMCPY // this give save as above *x = 0; memcpy(p, f, sizeof(p)); #endif return *x > 0; } Here's some screenshots that show what i mean. Screenshot #1 Screenshot #2
  5. Hi guys, i know this is stupid but i've been trying to convert this block of asm code in c++ for an hour or two and im stuck ////////////////////////////////////////////////////////////////////////////////////////////// /////// This routine write the value returned by GetProcAddress() at the address p /////////// ////////////////////////////////////////////////////////////////////////////////////////////// bool SetProcAddress(HINSTANCE dll, void *p, char *name) { UINT *res = (UINT*)ptr; void *f = GetProcAddress(dll, name); if(!f) return false; _asm { push ebx push edx mov ebx, f mov edx, p mov [ebx], edx // <--- put edx at the address pointed by ebx pop edx pop ebx } return res != 0; } ... // ie: SetProcAddress(hDll, &some_function, "function_name"); I tried: memcmp(p, f, sizeof(p)); and UINT *i1 = (*UINT)p; UINT *i2 = (*UINT)f; *f = *p; The first one dosent seem to give the right retult, and the second one won't compile. Any idea?
  6. Just out of curiosity, why the codes windows aren't showing a vertical bar for dragging when the text is more than x number of lines, for example? Or is there a way to do it? The site changed a lot since 3 years ago.
  7. Thanx, great reply. i'll start looking into that right now .
  8. Yeah but that way leave the node's data uninitialized, and a constructor/destructor allow, for example, a c string allocation/deallocation wich would be risky if T is a pointer (to a c string or whatever) uninitialized. Maybe im shooting for the impossible "etopia", something that just can't happen without a compromise? I know i tend to be a little (lot) perfectionist since a few years, it's like i know to many way to do the same things, and im never sure which one to use... Here's my whole code, just for fun... #pragma once //----------------------------------------------------------------------// #include <Windows.h> #include <stdio.h> //----------------------------------------------------------------------// template <class T> class LinkedList; //----------------------------------------------------------------------------- // Linked list node class //----------------------------------------------------------------------------- template <class T> class LinkedListNode { public: LinkedListNode(){prev = next = NULL;} private: T item; LinkedListNode<T> *prev, *next; public: friend class LinkedList<T>; T& GetItem(){return item;} T* GetItemPtr(){return &item;} void SetItem(T& it){item = it;} void SetItemPtr(T* it){item = *it;} LinkedListNode<T> *Prev(){return prev;} LinkedListNode<T> *Next(){return next;} }; //----------------------------------------------------------------------------- // Linked list class //----------------------------------------------------------------------------- template <class T> class LinkedList { public: LinkedList(); ~LinkedList(); public: typedef LinkedListNode<T> NODE; private: int NodesCount; NODE *head, *tail; private: void Initialize(); bool IndexInRange(int index); bool IndexOutOfBounds(int index); private: bool IsHead(NODE* n); bool IsTail(NODE* n); public: int GetSize(); bool IsEmpty(); NODE* GetNode(int index); NODE* GetFirstNode(); NODE* GetLastNode(); bool NodeExist(NODE* n); int FindNode(NODE* n); T* GetItem(int index); bool SetItem(int index, T& item); int FindItem(T& item); bool ItemExist(T& item); NODE* Push(T& item); NODE* Insert(int index, T& item); bool Delete(int index); bool Pop(); void Clear(); }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- // Constructor... //----------------------------------------------------------------------------- template <class T> LinkedList<T>::LinkedList() { Initialize(); } //----------------------------------------------------------------------------- // Destructor... //----------------------------------------------------------------------------- template <class T> LinkedList<T>::~LinkedList() { Clear(); } //----------------------------------------------------------------------------- // Initialise the list //----------------------------------------------------------------------------- template <class T> void LinkedList<T>::Initialize() { head = NULL; tail = NULL; NodesCount = 0; } //----------------------------------------------------------------------------- // Return true if the index is valid //----------------------------------------------------------------------------- template <class T> bool LinkedList<T>::IndexInRange(int index) { return index >= 0 && index < NodesCount; } //----------------------------------------------------------------------------- // Return true if the index is valid //----------------------------------------------------------------------------- template <class T> bool LinkedList<T>::IndexOutOfBounds(int index) { return index < 0 || index > NodesCount; } //----------------------------------------------------------------------------- // Return true if the list is empty //----------------------------------------------------------------------------- template <class T> bool LinkedList<T>::IsEmpty() { return NodesCount == 0; } //----------------------------------------------------------------------------- // Return the number of nodes in the list //----------------------------------------------------------------------------- template <class T> int LinkedList<T>::GetSize() { return NodesCount; } //----------------------------------------------------------------------------- // Return true if the given pointer is the head node //----------------------------------------------------------------------------- template <class T> bool LinkedList<T>::IsHead(NODE* n) { return head == n; } //----------------------------------------------------------------------------- // Return true if the given pointer is the tail node //----------------------------------------------------------------------------- template <class T> bool LinkedList<T>::IsTail(NODE* n) { return tail == n; } //----------------------------------------------------------------------------- // Return the node at the given position //----------------------------------------------------------------------------- template <class T> LinkedListNode<T>* LinkedList<T>::GetNode(int index) { int i = 0; NODE* node = head; while(node){ if(index == i) return node; node = node->Next(); i++; } return NULL; } //----------------------------------------------------------------------------- // Return the first node of the list //----------------------------------------------------------------------------- template <class T> LinkedListNode<T>* LinkedList<T>::GetFirstNode() { return head; } //----------------------------------------------------------------------------- // Return the last node of the list //----------------------------------------------------------------------------- template <class T> LinkedListNode<T>* LinkedList<T>::GetLastNode() { return tail; } //----------------------------------------------------------------------------- // Return true if the given node can be found in the list //----------------------------------------------------------------------------- template <class T> bool LinkedList<T>::NodeExist(NODE* n) { NODE* node = head; while(node){ if(node == n) return true; node = node->Next(); } return false; } //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- template <class T> int LinkedList<T>::FindNode(NODE* n) { int i = 0; NODE* node = head; while(node){ if(node == n) return i; node = node->Next(); i++; } return -1; } //----------------------------------------------------------------------------- // Return the node at given position //----------------------------------------------------------------------------- template <class T> T* LinkedList<T>::GetItem(int index) { if(IndexInRange(index)){ NODE* node = GetNode(index); if(node) return node->GetItemPtr(); } return NULL; } //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- template <class T> bool LinkedList<T>::SetItem(int index, T& item) { if(IndexInRange(index)){ NODE* node = GetNode(index); if(node){ node->SetItem(item); return true; } } return false; } //----------------------------------------------------------------------------- // new //----------------------------------------------------------------------------- template <class T> int LinkedList<T>::FindItem(T& item) { int i = 0; NODE* node = head; while(node){ if(node->GetItem() == item) return i; node = node->Next(); i++; } return -1; } //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- template <class T> bool LinkedList<T>::ItemExist(T& item) { return FindItem(item) >= 0; } //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- template <class T> LinkedListNode<T>* LinkedList<T>::Push(T& item) { NODE* new_node = new NODE; NodesCount++; // No head? if(!head){ head = new_node; tail = new_node; } else { // Update previous and next pointers new_node->prev = tail; tail->next = new_node; // Update the tail tail = new_node; } // Copy the node's data new_node->SetItem(item); return new_node; } //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- template <class T> LinkedListNode<T>* LinkedList<T>::Insert(int index, T& item) { if(IndexOutOfBounds(index)) return NULL; // Get a pointer to the node where we want to insert, if any NODE* node = GetNode(index); if(!node) return Push(item); // Allocate the new node NODE* new_node = new NODE; NodesCount++; // Update new node pointers new_node->next = node; new_node->prev = node ? node->prev : NULL; // Create next and previous node pointer NODE* prev_node = new_node->prev; NODE* next_node = new_node->next; // Update next and previous node pointer if(prev_node){prev_node->next = new_node;} if(next_node){next_node->prev = new_node;} // Update head and tail pointers if(!new_node->prev){head = new_node;} if(!new_node->next){tail = new_node;} // Copy the node's data new_node->SetItem(item); // Return the newly allocated node return new_node; } //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- template <class T> bool LinkedList<T>::Delete(int index) { // Check for index out of bounds exception... if(!IndexInRange(index) || IndexOutOfBounds(index)) return false; // Get prev and next nodes pointers NODE* node = GetNode(index); NODE* prev = node->Prev(); NODE* next = node->Next(); // Update prev and next nodes pointers if(prev){node->prev->next = next;} if(next){node->next->prev = prev;} // Update head and tail pointers if(IsHead(node)){head = node->next;} if(IsTail(node)){tail = node->prev;} // Delete the node delete node; NodesCount--; return true; } //----------------------------------------------------------------------------- // Remove the last node of the list //----------------------------------------------------------------------------- template <class T> bool LinkedList<T>::Pop() { return Delete(NodesCount - 1); } //----------------------------------------------------------------------------- // Clear the entire list //----------------------------------------------------------------------------- template <class T> void LinkedList<T>::Clear() { while(Pop()); } Feel free to critic.
  9. yea that's my problem, how do i cope with this? I mean, i cannot in advance since T could be anything... That's a good point.
  10. Why not use a high-precision timer? You can look at mine (Timer.h, Timer.cpp) for example . I always used this kind of timer when coding a game and it always gave me great result in the past. Honestly, what's the point of fixed timestep except in some circumstance, and hard coded frames per seconds limits if you can just use vsync to do the job for you? Just my 2 cents here...
  11. I guys, i have some questions regarding the design of my node class for a linked list or stack or whatever... Let's show me some code, then i'll explain: //----------------------------------------------------------------------------- // Linked list node class //----------------------------------------------------------------------------- template <class T> class LinkedListNode { public: LinkedListNode(){prev = next = NULL;} private: T item; LinkedListNode<T> *prev, *next; public: T GetItem(){return item;} void SetItem(T it){item = it;} LinkedListNode<T> *Prev(){return prev;} LinkedListNode<T> *Next(){return next;} }; That method is fine, but waste time in GetItem()/SetItem(), so, i could add those 2 methods, ie: T* GetItemPtr(){return &item;} void SetItemPtr(T *it){item = *it;} But that's ugly, and even if i use only one set of GetItem()/SetItem(): ie replace previous code with: T* GetItem(){return &item;} void SetItem(T *it){item = *it;} or T& GetItem(){return item;} void SetItem(T &it){item = it;} it seem each methods has his pros and cons. What's worst is that you can't use more than one set or the compiler will cry... Also, if the object T is not a class, but a simple variable (an int for example), it dosen't have a constructor, and im not sure if: ZeroMemory(&item, sizeof(item)); will work on any kind of data (especially classes). Any advice?
  12. Hi guys, long time no see! (I was pretty active a few years ago on this forum ). Anyway, long story short, I want to make apps for my android phone, but after following some tutorials and ending up cloging my hard drive for nothing, i can't seem to be able to put all the pieces together concerning all the crap to install, since there's always something that changed since when the tutorial was wrote, or stuffs like that. Im usually not a noob to this kind of things but it seem there's always something going wrong when i try (it's like the modules im installing in eclipse just never end, im always missing something, argggg!) Let's say i start a fresh copy of Win7 in VMWare, can somebody tell me the EXACT steps to perform, in order, so that i can compile an app without problem, i know im asking a lot, but i believe that's a fair thing to ask, since it might help others peoples that land to this post too. I would really like a recipe kind of answer, lol. Also, i know this sound dumb, but anyway, i have no idea how the compilation work, wich file or files get created as output, and, the most important, how the heck do i load this thing in the cellphone, do i HAVE to use google store, or is it optional? Im used as a win32 programmer, i know almost nothing yet of android platform ) . Im not in a hurry for an answer, so take all the time you need to give a detailled explanation please (otherwise im back to square one!) Thx in advance for your time.
  13. Hi, i just wanted to know if it's possible to compute a hash on the gpu, like crc32 or something stronger(sha-1?) , in an efficient manner? If so, how, how would i retreive the result?
  14. Hi guys, i've been toying with the "game of life" for a few days, and been able to achieve blazing speed by using shaders to compute the next generation on the gpu (it can also do all the work on the cpu, so i can compare both methods speed). The problem i have is this: at some point, the game will be "stuck", generating the same 2 frames over and over, alternating between them forever... I need a way to detect this. If i do it on the cpu, it's easy since i could just compare the last few frames to see if the game is stuck, using memcmp, or even better, generate a hash while computing the next gen and just compare the last few of them. Easy. But when i use the gpu path, i only have the first frame in client memory (ram), and i don't know how to solve this problem other than use the slow glReadPixel. Perhaps a PBO could help, but im not very familliar with them. From what i remember, it wouldn't be that much faster anyway. What i want is some clever way to do that without losing too much framerate. So, any though? ///////////////////////////////////////////////////////////////////////// Those 2 files simply show how i use the code for both mode: CPU example code.txt GPU example code.txt Those are the 2 main classes of the project: GLEngine.h GLEngine.cpp The game of life.h The game of life.cpp Note:  (most relevant bits of code is near the bottom of each files) And finally, the shaders: Life.vs + Life.fs If you see anything i can improve on, please let me know!
  15. Vortez

    Proper C++ header file?

    I would also suggest to replace   #ifndef INCLUDED_TILEMAP_H #define INCLUDED_TILEMAP_H   by   #pragma once   it's simpler and you don't need the #endif at the end :)
  • 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!