Jump to content
  • Advertisement

Shock

Member
  • Content Count

    108
  • Joined

  • Last visited

Community Reputation

140 Neutral

About Shock

  • Rank
    Member

Recent Profile Visitors

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

  1. Shock

    D3DXCreateTextureFromFile

    Heya Dev, Im a D3D9 n00b, but I will let you know what I have come across. I don't use dynamic textures though. I call IDirect3DDevice9::CreateTexture()specifying I am using the managed pool ( something dynamic textures dont do ) and either D3DFMT_A8R8G8B8 or D3DFMT_DXTn as a format. Lock the texture, copy my data, unlock and it works for me. So far I got it to load the following directly: PNG ( 24/32 ) TGA ( 24/32 ) DDS ( 1/3/5 ) For 24 bit formats I convert to 32 bit using a replacement alpha value of 255. So far any format other than the 32 Bit nd DXTn ones fail. Stuff like 24 Bit, Alpha luminance, etc...haven't tried 16 Bit though. But otherwise...it works this way. - Shock
  2. Shock

    HAL not available?

    Your'e cleaning up all wrong. You release the device BEFORE direct3d itself. Try this: // Macro to easily release interfaces #define SAFE_RELEASE(p) if(p) { p->Release(); p = 0; } // Release device and direct3d SAFE_RELEASE( Device ); SAFE_RELEASE( D3D ); - Shock
  3. Here's another image that shows what I actually generate. As you can see, my only problem is that I need to offset certain characters into their correct positions. I looked at the documentation and NeHe's tutorial #43. He does some weird translating in order to get the positions right. He casts each glyph to an FT_BitmapGlyph to get two positions, left and top. The freetype docs say: Quote: left The left-side bearing, i.e., the horizontal distance from the current pen position to the left border of the glyph bitmap. top The top-side bearing, i.e., the vertical distance from the current pen position to the top border of the glyph bitmap. This distance is positive for upwards-y! Then theres some other the 'advance vector' from the generated glyph character itself ( FTGlyph ). I don't know what this really does. I would appreciate it if someone who got freetype character positioning right to reply. Doesn't matter how you used it, just what you ddid to get it right. Thanks
  4. Heya all, I have got freetype to generate characters for me. I then take the character data and copy them to a single texture. I am padding every character to make its width and height the closest power of 2. e.g 32x32. My problem is the way the characters get drawn. I know I am supposed to offset my start copy/draw positions. What I don't know is where I get these values from. The image below shows my problem. Image Link As you can see characters overlap and some are vertically positioned wrong. How can I solve this problem? Thanks
  5. Greetings all, I have a few problems with freetype and D3D9 I hope you could help me with. Ok I have no problem with the freetype library. The problem is what to do after I generated the glyph's for every character. I was thinking of taking all my characters and storing in them in a single texture. I need to know however, what format the bitmap data is in...I have looked at the docs, but I could not find it. If anyone has generated a texture with this data, what D3DFMT_ did you use? Another thing is after I generate my characters and compose it into a texture. How do I add the 'color' when rendering characters? Would my polygon's need to be vertex lit with the color I want? When freetype generates the characters, how can I find out the width of each character? Please help! Thanks
  6. Heya all, I am trying to load a 32 Bit PNG file. I created the file in photoshop and it has transparent parts. I am using my own image loader ( using libpng ). When I load this and use it, the transparent areas are light blue! But wait, before you say "there's a problem with your loader code". I used D3DX to load the image...same result! So I went and: Open with windows image viewer: Transparency is correct Open with windows paint: Transparency is light blue! I don't know what is wrong. I tried different exporters to! When I use Paint Shop Pro the transparent sections become black. Any advice? I did not turn any alpha blending settings on in D3D. Do I have to? I tried this same thing using 32Bit TGA / DDS and the transparency works perfectly without enabling alpha related states. Please help, Thanks! - Shock
  7. Heya Namethatnobodyelsetook, Thank you very much, I reset the far and near planes to 1.0 and 3.0 and it all works...except for one thing. It seems the Y is reversed? ^O_o^ Is this supposed to be happening or didn't I set something ? - Shock
  8. Heya, I am trying to get orthographic rendering working for my D3D9 renderer. So far I have had no luck. I have googled the forums...but each solution I could find doesn't remedy my problem. Heres my code: #define TEST_FVF ( D3DFVF_XYZ ) // Get identity and create ortho matrix D3DXMATRIX identity, ortho; D3DXMatrixOrthoOffCenterLH( &ortho, 0, Window->GetWindowWidth()-1, 0, Window->GetWindowHeight()-1, -1.0f, 1.0f ); D3DXMatrixIdentity( &identity ); // Set transforms d3d9_device->SetTransform( D3DTS_WORLD, &identity ); d3d9_device->SetTransform( D3DTS_VIEW, &identity ); d3d9_device->SetTransform( D3DTS_PROJECTION, &ortho ); // Setup simple test triangle struct Vertex { float x, y, z; }; Vertex triangle[] = { { 0, 0, 0.5 }, { 100, 0, 0.5 }, { 0, 100, 0.5 }, }; The above will not render. If I use transformed vertices ( D3DFVF_XYZRHW and add rhw component in vertex structure ) it renders perfectly. Lighting and Z is off. What am I doing wrong? Thanks!
  9. Shock

    Window size anomaly

    Heya CodeZero, Are you in Orthographic mode? If so I may have encountered your problem. The problem was either calls to glOrtho or glViewport or both. I specified zero for top and left boundaries. This made OpenGL render behind the window frames/top bar. To remedy the problem I used window coordinates using GetClientRect(). That is what worked for me. This only happened in windowed mode of course. :) HTH Shock
  10. Heya, Well I basically want to know if I am entering/leaving ortho mode properly and if I am using the correct stuff for glViewport. My problems is my use rinterface, when I start it up OpenGL matches my ui coordinates ( pixels ) perfectly. However when I resize the window or change resolutions, it all goes to heck. It's like the new resolution affects the coordinates system of the orthographic projection. Somehow I think I am not calling something, or am not giving it the right parameters.
  11. Heya all, I am making a gui system using opengl in orthographic mode. Everything is fine when I start up with a resolution of 800x600. When I maximize the window( 1024x768 ), the mouse coordinates don't seem to be matching opengl's coordinates. E.g I use the mouse to move a window ( at 800x600 ) and the window will be drawn perfectly according to where i place the mouse. If I change resolution the quad 'runs away' from the cursor. Also the quad seems to be bigger at a high resolution. Isn't the opposite supposed to happen. I am handling window size messages and do resize my viewport when this happens. Here is the code I use for orthographic mode and resizing my viewport. //********************************************************************************************// // ResizeViewport() - Resize renderer viewport //********************************************************************************************// void ResizeViewport() { glViewport( 0, 0, Window.GetWindowWidth(), Window.GetWindowHeight()); } //********************************************************************************************// // EnterOrthoMode() - Enter orthographic mode //********************************************************************************************// void EnterOrthoMode() { // Get current viewport values GLint viewport[4]; glGetIntegerv( GL_VIEWPORT, viewport ); // Push on a new projection matrix glMatrixMode( GL_PROJECTION ); glPushMatrix(); glLoadIdentity(); // Specify orthographic region glOrtho( 0.0f, viewport[2], viewport[3], 0.0f, -1.0f, 1.0f ); // Push on a new model-view matrix glMatrixMode( GL_MODELVIEW ); glPushMatrix(); glLoadIdentity(); } //********************************************************************************************// // LeaveOrthoMode() - Leave orthographic mode //********************************************************************************************// void LeaveOrthoMode() { // Pop back projection matrix glMatrixMode( GL_PROJECTION ); glPopMatrix(); // Pop back model-view matrix glMatrixMode( GL_MODELVIEW ); glPopMatrix(); } I am using win32's GetCursorPos() and ScreenToClient() for getting my mouse coordinates. What do I need to do to make resolution changes play nice with opengl? Thanks
  12. Thank you! I was struggling with this problem for a while, LOL.
  13. Hello all, I am trying to calculate texture coordinates for my gui using pixel values. Reason for doing this is because all my gfx for my gui is in a single texture. I know it something very simple to do, but what I tried doesn't work. #define pix2tex( pixel, size ) ((1.0f / size-1 ) * pixel ) Please tell me where I am going wrong. Thanks :)
  14. Heya all, Let me post some example code firstly: // Describe tests that can be done enum Tests { TEST_ONE = 1, TEST_TWO, TEST_THREE, }; // Set the tests that we should perform unsigned int tests = TEST_ONE | TEST_THREE; // Check which tests we want done if ( ( tests & TEST_ONE ) == TEST_ONE ) DoTestOne(); if ( ( tests & TEST_TWO ) == TEST_TWO ) DoTestTwo(); if ( ( tests & TEST_THREE ) == TEST_THREE ) DoTestThree(); The problem I have with the above is even though only test one and three are specified, the check for test two evalutes to true! I don't think I am doing this properly, I have google'd for tutorials on how to do this properly, but I cant find any examples. Please help me! Thanks
  15. Damn, stupid me. It wasn't D3D, it was my depth sorter. It seems it isn't sorting components correctly and was always setting 0.0f for the Z regardless of what was 'activated'. Can anyone give me a clue on how to do depth sorting for my GUI ?
  • 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!