Jump to content
  • Advertisement

giant

Member
  • Content count

    202
  • Joined

  • Last visited

Community Reputation

205 Neutral

About giant

  • Rank
    Member
  1. Hey Ive spent a few hours looking and cant find any information on this, probably because it cant be done and Im foolish for thinking that it may be possible, however before giving up I thought it good to ask here so that a) I may find an answer and b) if someone else looks in the future they too can find the answer here. I have a shader in GLSL. If creates some noise using BFM. Originally I tried to split this noise (which represents a height) into 3 or 4 floats in the range 0.0 to 1.0, and store them in the RGBA of the texture, however I would like to know if its possible to setup a texture in some way so that it allows full floats to be stored in each of its RGBA values i.e. in the RGB of a texture I can store a complete vertex position. (1234.56, 78.90123, 45.67866) The best direction I could find in some google research was to use GL_RGBA_FLOAT32_ATI as below, however this does not seem to work for me. I will keep trying and post back here if I find a solution, however any tips, advice (on if possible or not) would be greatly appreciated. glGenTextures(1, &m_uiTexture); glBindTexture(GL_TEXTURE_2D, m_uiTexture); /*glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_uiWidth, m_uiHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);*/ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA_FLOAT32_ATI, m_uiWidth, m_uiHeight, 0, GL_RGBA, GL_FLOAT, 0); glBindTexture(GL_TEXTURE_2D, 0); Thanks alot. Ciaran
  2. Thanks. That makes perfect sence. Ive already used it for reflections and shadowmaps. I really should have put 2 and 2 together and realised the solution myself. Thanks again for the reply.
  3. Hi My 3D engine has dynamic terrain and planet generation. At present the topography and textures are created in software which is of course a little slow, especially when moving quickly towards a planet as it recursively subdivides the mesh and generates the texture in higher detail. I dont even know if what I want is possible, but can I create this texture in a shader? Is there an equilavent to the tex2D function in CG that sets the texture data rather than sampling it? (based on terrain height)? Google hasnt helped me much so far, but I could well be searching for the wrong thing. How would you implement what I am discussing? Thanks in advance,
  4. giant

    Can't read joystick output

    Hi There probbaly are some issues with my implementation but if it will help you I shall post the code here. #define JOYSTICK_PRESSED 255 struct sJoystickState { short XAxis; short YAxis; bool ButtonPressed[36]; }; class CJoystick { //Private Member Variables private: LPDIRECTINPUTDEVICE8 m_pJoystick; //Pointer to DirectInput Joystick DIJOYSTATE m_dxJoystickState; //DirectX State of Joystick sJoystickState m_decadeJoystickState; //Decade State of Joystick char m_pszJoystickName[260]; //Name of the Joystick //Public Member Variables public: CJoystick(); ~CJoystick(); bool Initialise(HWND p_hWnd, LPDIRECTINPUT8 p_pDirectInput, GUID p_guidDevice, char* p_pszDeviceName); char* get_JoystickName(); sJoystickState* get_State(); }; CJoystick::CJoystick() { ZeroMemory(&m_decadeJoystickState, sizeof(sJoystickState)); m_pJoystick = NULL; } CJoystick::~CJoystick() { if (NULL != m_pJoystick) { m_pJoystick->Unacquire(); m_pJoystick->Release(); } } bool CJoystick::Initialise(HWND p_hWnd, LPDIRECTINPUT8 p_pDirectInput, GUID p_guidDevice, char* p_pszDeviceName) { //Save the Device Name strcpy_s(m_pszJoystickName, 260, p_pszDeviceName); //Create the Joystick Device LPDIRECTINPUTDEVICE8 l_pCurrentInputDevice = NULL; p_pDirectInput->CreateDevice(p_guidDevice, &l_pCurrentInputDevice, NULL); if (FAILED(l_pCurrentInputDevice->QueryInterface(IID_IDirectInputDevice8, (void**)&m_pJoystick))) { return false; } SAFE_RELEASE(l_pCurrentInputDevice); //Set cooperative level if (FAILED(m_pJoystick->SetCooperativeLevel(GetDesktopWindow(), DISCL_BACKGROUND | DISCL_NONEXCLUSIVE))) { return false; } if (FAILED(m_pJoystick->SetDataFormat(&c_dfDIJoystick))) { return false; } //Set range and dead zones //X Range DIPROPRANGE l_JoystickRange; l_JoystickRange.lMin = -JOYSTICK_PRESSED; l_JoystickRange.lMax = JOYSTICK_PRESSED; l_JoystickRange.diph.dwSize = sizeof(DIPROPRANGE); l_JoystickRange.diph.dwHeaderSize = sizeof(DIPROPHEADER); l_JoystickRange.diph.dwObj = DIJOFS_X; l_JoystickRange.diph.dwHow = DIPH_BYOFFSET; m_pJoystick->SetProperty(DIPROP_RANGE, &l_JoystickRange.diph); //Y Range l_JoystickRange.lMin = -JOYSTICK_PRESSED; l_JoystickRange.lMax = JOYSTICK_PRESSED; l_JoystickRange.diph.dwSize = sizeof(DIPROPRANGE); l_JoystickRange.diph.dwHeaderSize = sizeof(DIPROPHEADER); l_JoystickRange.diph.dwObj = DIJOFS_Y; l_JoystickRange.diph.dwHow = DIPH_BYOFFSET; m_pJoystick->SetProperty(DIPROP_RANGE, &l_JoystickRange.diph); //Acquire the Joystick if (FAILED(m_pJoystick->Acquire())) { return false; } //Poll the Joystick if (FAILED(m_pJoystick->Poll())) { return false; } return true; } char* CJoystick::get_JoystickName() { return m_pszJoystickName; } sJoystickState* CJoystick::get_State() { if (NULL != m_pJoystick) { if (FAILED(m_pJoystick->GetDeviceState(sizeof(DIJOYSTATE), (LPVOID)&m_dxJoystickState))) { while (DIERR_INPUTLOST == m_pJoystick->Acquire()); return &m_decadeJoystickState; } m_decadeJoystickState.XAxis = (short)m_dxJoystickState.lX * -1; m_decadeJoystickState.YAxis = (short)m_dxJoystickState.lY * -1; for (int l_iButton = 0; l_iButton < 32; l_iButton++) { if (m_dxJoystickState.rgbButtons[l_iButton] > 32) m_decadeJoystickState.ButtonPressed[l_iButton] = true; else m_decadeJoystickState.ButtonPressed[l_iButton] = false; } switch (m_dxJoystickState.rgdwPOV[0]) { case -1: { m_decadeJoystickState.ButtonPressed[32] = false; // UP m_decadeJoystickState.ButtonPressed[33] = false; // RIGHT m_decadeJoystickState.ButtonPressed[34] = false; // DOWN m_decadeJoystickState.ButtonPressed[35] = false; // LEFT break; } case 0: { m_decadeJoystickState.ButtonPressed[32] = true; // UP m_decadeJoystickState.ButtonPressed[33] = false; // RIGHT m_decadeJoystickState.ButtonPressed[34] = false; // DOWN m_decadeJoystickState.ButtonPressed[35] = false; // LEFT break; } case 4500: { m_decadeJoystickState.ButtonPressed[32] = true; // UP m_decadeJoystickState.ButtonPressed[33] = true; // RIGHT m_decadeJoystickState.ButtonPressed[34] = false; // DOWN m_decadeJoystickState.ButtonPressed[35] = false; // LEFT break; } case 9000: { m_decadeJoystickState.ButtonPressed[32] = false; // UP m_decadeJoystickState.ButtonPressed[33] = true; // RIGHT m_decadeJoystickState.ButtonPressed[34] = false; // DOWN m_decadeJoystickState.ButtonPressed[35] = false; // LEFT break; } case 9000+4500: { m_decadeJoystickState.ButtonPressed[32] = false; // UP m_decadeJoystickState.ButtonPressed[33] = true; // RIGHT m_decadeJoystickState.ButtonPressed[34] = true; // DOWN m_decadeJoystickState.ButtonPressed[35] = false; // LEFT break; } case 18000: { m_decadeJoystickState.ButtonPressed[32] = false; // UP m_decadeJoystickState.ButtonPressed[33] = false; // RIGHT m_decadeJoystickState.ButtonPressed[34] = true; // DOWN m_decadeJoystickState.ButtonPressed[35] = false; // LEFT break; } case 18000+4500: { m_decadeJoystickState.ButtonPressed[32] = false; // UP m_decadeJoystickState.ButtonPressed[33] = false; // RIGHT m_decadeJoystickState.ButtonPressed[34] = true; // DOWN m_decadeJoystickState.ButtonPressed[35] = true; // LEFT break; } case 18000+9000: { m_decadeJoystickState.ButtonPressed[32] = false; // UP m_decadeJoystickState.ButtonPressed[33] = false; // RIGHT m_decadeJoystickState.ButtonPressed[34] = false; // DOWN m_decadeJoystickState.ButtonPressed[35] = true; // LEFT break; } case 18000+9000+4500: { m_decadeJoystickState.ButtonPressed[32] = true; // UP m_decadeJoystickState.ButtonPressed[33] = false; // RIGHT m_decadeJoystickState.ButtonPressed[34] = false; // DOWN m_decadeJoystickState.ButtonPressed[35] = true; // LEFT break; } } } else { ZeroMemory(&m_decadeJoystickState, sizeof(sJoystickState)); } return &m_decadeJoystickState; } As suggested by Reegan, filling the DIPROPRANGE tells DirectInput to return a value between Min and Max for each Axis of the Joystick. (Here I set it to -255, 255). Ciarán
  5. giant

    Can't read joystick output

    I dont know to much about DirectInput but I do have it working in my 3D engine. I followed a tutorial somewhere or referenced a book. The one difference I can see between your implementation and mine is that I do not call Poll each time. if (FAILED(m_pJoystick->GetDeviceState(sizeof(DIJOYSTATE), (LPVOID)&m_dxJoystickState))) { while (DIERR_INPUTLOST == m_pJoystick->Acquire()); return &m_decadeJoystickState; } m_decadeJoystickState.XAxis = (short)m_dxJoystickState.lX * -1; m_decadeJoystickState.YAxis = (short)m_dxJoystickState.lY * -1; for (int l_iButton = 0; l_iButton < 32; l_iButton++) { if (m_dxJoystickState.rgbButtons[l_iButton] > 32) m_decadeJoystickState.ButtonPressed[l_iButton] = true; else m_decadeJoystickState.ButtonPressed[l_iButton] = false; } I call Poll once at the end of the Init function, (after calling Acquire).
  6. giant

    vba textures?

    Do you mean VBO? (Vertex Buffer Objects)
  7. giant

    A question about lighting

    Hi I think I know what you are refering to. Check out this video. I believe the technique you are refering to is when they used really high poly models in a lit environment to generate the textures which are then applied to low poly models, making them look as though they have alot more detail than they actually do. I can not answer your question here about what you can do with lighting to make the model look better. That is a huge area of discussion of which there are many tutorials and research papers online. You should not change the position of the light for each mesh unless you have reason too. I might create a strange effect, however if you are looking for a realistic look this would definately be the wrong thing to do. Ciarán
  8. giant

    Modeling a planet?

    Hi Boweevil I have multiple versions of my engine. When I started I didnt really have an end goal. It was a learning and fun experience so I have tried many platforms and technologies. My main engine is in C++ and OpenGL. I have built this for Windows and Linux (Ubuntu). I also have a C# version of my engine running under windows however this is only about 80% up to date. Even though I started with OpenGL I always knew I wanted DX as well (Before this project I had no OpenGL experience. All was DX) therefore I have implemented a good Graphics Abstraction Layer. When I reach a milestone (yet to be defined) I am going to rewrite the GAL allowing my engine to work with DX/XNA/OpenGL etc.... Everything in my engine has been coded from scratch by myself. Take a look on my website or search for "Decade Engine" on youtube for a selection of videos showing the basic features. In the early days I followed some online tutorials showing how to render a terrain etc.. With limited information available on planets I have implemented this myself based on what I have learned previously. I am unsure about editing procedural planets. If I am at point A and move to point B which is a distance away, the data at point A may be deleted from memory. When I go back to point A the data is generated again on the fly. This will prevent the persistance of any editing you do to your planet. One of my indevelopment features is that when a part of the planet is out of range and to be deleted, it can be saved to a temp file on disk with this file being loaded if this area of the planet is revisited rather than it being generated agian. It would be possible for you to do this for any part of the terrain that is edited during game play. If you require a planet to be edited from the very beginning this approach could also be used with the edited planet patches being supplied in heighmap files that are loaded when that patch is needed instead of generated. Depending on the level of modification this may become a problem as the data becomes large. I will be happy to try and answer any questions that you have.
  9. giant

    Modeling a planet?

    Hi I am currently developing a planet renderer for my 3D engine. You can check out a video at my website. The planet in my current video is generated procedurally however doesnt increase in detail as the camera gets closer to the planet. This is almost complete and I should have a video soon. As this is my first attempt at generating planets it is all done on the CPU. I hope to start using the GPU for some of the processing soon. To generate procedurally means that the entire planet is generated within your program. It is not loaded from a file or resource. My implementation used Fractional Brownian motion to generate 3D noise for the planet. This allows me to have different levels of detail when far away and up close. I can in theory have a planet which has resolution down to 1mm. Storing a planet of this complexity in a file would be HUGE.... not to mention how difficult it would be to load the data for different resolutions. (You obviously dont want to render the planet at 1mm resolution when the camera is 100km away) When generated procedurally it is still possible to recreate the same planet over and over again. By using the same seed number (Think of this as a unique planet ID) your noise function will produce the same outputs (Random number generators are not truely random. They are pseudo random so it is possible to get the same output). In basic terms (where I am in my development) I dont have much control over the geography of my planet however with with tens of thousands of possibilities its quiet easy to find a nice looking planet, and with more complexity added to my planet generation functionality I will be able more accurately control the finer details. If you would like to discuss any of the methods I used etc... please feel free to message me. Ciarán
  10. giant

    Mutex never locks

    Hi Dave I have tried Critical Section but get the same error as before. My Critical Section code is as follows #ifndef DECADE_MUTEX_HEADER_H #define DECADE_MUTEX_HEADER_H #include <windows.h> class CMutex { //Private Member Variables private: CRITICAL_SECTION m_Mutex; char m_pszMutexName[256]; //Public Member Variables public: //Private Member Functions private: //Public Member Functions public: CMutex(); ~CMutex(); void Create(char* p_pszName = NULL); void Close(); BOOL Lock(int p_iTimeout = 1000); BOOL Unlock(); }; #endif #include "Mutex.h" #include "Debug.h" CMutex::CMutex() { } CMutex::~CMutex() { Close(); } void CMutex::Create(char* p_pszName) { memset(m_pszMutexName, 0x00, sizeof(char) * 256); if (NULL != p_pszName) strcpy_s(m_pszMutexName, 256, p_pszName); InitializeCriticalSection(&m_Mutex); } void CMutex::Close() { DeleteCriticalSection(&m_Mutex); } BOOL CMutex::Lock(int p_iTimeout) { EnterCriticalSection(&m_Mutex); CDebug::Log("Debug.txt", "Mutex %s Locked by Thread %d\n", this->m_pszMutexName, GetCurrentThreadId()); return TRUE; } BOOL CMutex::Unlock() { LeaveCriticalSection(&m_Mutex); CDebug::Log("Debug.txt", "Mutex %s Unlocked by Thread %d\n", this->m_pszMutexName, GetCurrentThreadId()); return TRUE; } And again the Debug shows that both threads are entering the Critical Section at the same time Mutex Planet Locked by Thread 1176 1176 CPlanet::Update Mutex Planet Locked by Thread 2268 2268 CPlanet::Render 2268 CPlanet::Render FRONT 2268 CPlanetPatch::Render. Rendering NorthWest Child 2268 CPlanetPatch::Render. Rendering Patch ... .. .
  11. giant

    Mutex never locks

    Hi Dave Thanks for the reply. Prehaps I am testing from an incorrect point of view. I'll try and explain my real runtime condition for you. I am currently doing some work on procedural planets. I want the planet updating to take place on a different thread than the rendering. void CPlanet::Render(CCamera* p_pCamera) { if (TRUE == m_Mutex->Lock(60000)) { CDebug::Log("Debug.txt", "%d CPlanet::Render\n", GetCurrentThreadId()); CObject::StartRendering(p_pCamera); if (NULL != m_pDetailTexture) { m_pDetailTexture->Bind(GL_TEXTURE1_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2); } m_pCamera = p_pCamera; CDebug::Log("Debug.txt", "%d CPlanet::Render FRONT\n", GetCurrentThreadId()); m_pFaces[FRONT].Render(p_pCamera); CDebug::Log("Debug.txt", "%d CPlanet::Render RIGHT\n", GetCurrentThreadId()); m_pFaces.Render(p_pCamera); CDebug::Log("Debug.txt", "%d CPlanet::Render BACK\n", GetCurrentThreadId()); m_pFaces[BACK].Render(p_pCamera); CDebug::Log("Debug.txt", "%d CPlanet::Render LEFT\n", GetCurrentThreadId()); m_pFaces.Render(p_pCamera); CDebug::Log("Debug.txt", "%d CPlanet::Render TOP\n", GetCurrentThreadId()); m_pFaces[TOP].Render(p_pCamera); CDebug::Log("Debug.txt", "%d CPlanet::Render BOTTOM\n", GetCurrentThreadId()); m_pFaces[BOTTOM].Render(p_pCamera); if (NULL != m_pDetailTexture) m_pDetailTexture->Unbind(GL_TEXTURE1_ARB); CObject::EndRendering(p_pCamera); m_Mutex->Unlock(); CDebug::Log("Debug.txt", "%d CPlanet::Render Complete\n", GetCurrentThreadId()); } } The Planet Update Function is void CPlanet::Update(CCamera* p_pCamera) { if (TRUE == m_Mutex->Lock(60000)) { CDebug::Log("Debug.txt", "%d CPlanet::Update\n", GetCurrentThreadId()); m_pFaces[FRONT].Update(p_pCamera); m_pFaces.Update(p_pCamera); m_pFaces[BACK].Update(p_pCamera); m_pFaces.Update(p_pCamera); m_pFaces[TOP].Update(p_pCamera); m_pFaces[BOTTOM].Update(p_pCamera); m_Mutex->Unlock(); CDebug::Log("Debug.txt", "%d CPlanet::Update Complete\n", GetCurrentThreadId()); } } which is called by a seperate thread DWORD WINAPI PlanetThread(LPVOID p_Parameter) { CPlanet* l_pPlanet = (CPlanet*)p_Parameter; while(1) { l_pPlanet->Update(l_pPlanet->m_pCamera); Sleep(50); } return 0; } With this setup I would hope that the system would lock and rendering/updating take place at seperate times, however the debug file shows... 2256 CPlanet::Update 1212 CPlanet::Render Complete 1212 CPlanet::Render 1212 CPlanet::Render FRONT 1212 CPlanetPatch::Render. Rendering NorthWest Child 2256 CPlanet::Update Complete 1212 CPlanetPatch::Render. Rendering Patch ... .. . How would I ensure that when the planet is updating that no rendering takes place. (Please note that this is not my ultimate goal. I want updating and rendering to take place at the same time, however certain sections need to be critical. Its just easier to explain and test in this form) I have tried using CriticalSection however this also did not appear to work. Is this the right area? Thanks
  12. Hi I have been looking online and on gamedev forums for this problem, but most people appear to suffer from their programs locking up. I have the opposite. I want to lock thread A at a specific point until thread B completes. I am working in VS 2005/C++ and using Mutex's. My Mutex Code is like #include "Mutex.h" CMutex::CMutex() { m_Mutex = NULL; } CMutex::~CMutex() { if (NULL != m_Mutex) Close(); } void CMutex::Create() { m_Mutex = CreateMutex(NULL, FALSE, NULL); } void CMutex::Close() { if (NULL != m_Mutex) { CloseHandle(m_Mutex); m_Mutex = NULL; } } BOOL CMutex::Lock(int p_iTimeout) { switch(WaitForSingleObject(m_Mutex, p_iTimeout)) { case WAIT_OBJECT_0: return TRUE; case WAIT_ABANDONED: case WAIT_TIMEOUT: case WAIT_FAILED: return FALSE; } return FALSE; } BOOL CMutex::Unlock() { return ReleaseMutex(m_Mutex); } My program was crashing due to some sync issues. To test my mutex code I added some test commands into a sample program. m_Mutex = new CMutex(); m_Mutex->Create(); if (TRUE == m_Mutex->Lock(50000)) { if (TRUE == m_Mutex->Lock(60000)) { etc.... } } I would expect this to lock as the mutex is acquired in the first lock, and will never be released, allowing the second lock to continue, however WAIT_OBJECT_0 is returned from each call to WaitForSingleObject Any help you can give would be great. All my research shows that I am doing things correctly. http://msdn.microsoft.com/en-us/library/ms686927(VS.85).aspx
  13. giant

    2d grids

    I think the phrase "2D Grid" is used to describe what is seen rather than the actual functionality in the code. The grid drawn changes in the X and Z axis, therefore resulting in a flat grid and when viewed from above looks 2D. If you want to use propper 2D graphics define the 2D orthographic projection matrix glViewport(p_iXPosition, p_iYPosition, p_iWidth, p_iHeight); //Set Up Ortho Mode To Fit the Viewport gluOrtho2D(0, p_iWidth, p_iHeight, 0); and then use glVertex2f instead of glVertex3f
  14. giant

    problem with bitmap loading code

    Can you define in more detail what you mean by "bitmaps aren't showing up properly"?
  15. giant

    List of graphic items

    You would not create an album list in OpenGL. OpenGL is a graphics API and can therefore only be used for graphics (such as rendering the GUI for your Album list). The list will be programmed in whatever language you are using. (C++, C#). You would also not use BSP for this. BSP is for partioning 3d space so that only the visible area is rendered. Do some research on Listed Lists, Double Linked lists or Binary Trees (if you want something more challenging).
  • 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!