Jump to content
  • Advertisement

DJLaitier

Member
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

100 Neutral

About DJLaitier

  • Rank
    Newbie
  1. DJLaitier

    Frame Problem with Bitmaps

    ahhh, i hadn´t understood it. so, my handle Array is getting filled with the reference of the bitmap, so i can save the value of my variable, and later i can use it like a pointer ?
  2. DJLaitier

    Frame Problem with Bitmaps

    uhm, i think, i´m too stupid to find the FAQ ^^ And just another question: my int-variable "handle" never gets a value, does it? Gl.glGenTextures(handle.Length, handle); That´s the only Row, where it´s been used so, i think, it doesn´t get a value, it´s just an int- array
  3. DJLaitier

    Frame Problem with Bitmaps

    Well, my Textures are in an Bitmap Array, and i just draw them on the Quads.. Or do you mean, i should use Pointers?
  4. Hello Community, I´ve got a problem with the texturing of some Quads (about 4000) in a 2D Projection. @ first: Here´s the code int x = 0; int y = 0; m_Width = 32; m_Height = 32; handle = new int[1]; m_Handle = handle[0]; Gl.glGenTextures(handle.Length, handle); rect = new Rectangle(0, 0, m_Width, m_Height); while (x < 30) { while (y < 30) { bitmap = (Bitmap)values.bmpBackgroundArray[x, y].Clone(); bdata = bitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, bitmap.PixelFormat); Gl.glBindTexture(Gl.GL_TEXTURE_2D, m_Handle); Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, m_Width, m_Height, 0, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bdata.Scan0); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR); Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glBegin(Gl.GL_QUADS); Gl.glTexCoord2f(0, 0); Gl.glVertex2f(x * 32, y * 32); Gl.glTexCoord2f(0, 1); Gl.glVertex2f(x * 32, y * 32 + m_Height); Gl.glTexCoord2f(1, 1); Gl.glVertex2f(x * 32 + m_Width, y * 32 + m_Height); Gl.glTexCoord2f(1, 0); Gl.glVertex2f(x * 32 + m_Width, y * 32); Gl.glEnd(); Gl.glDisable(Gl.GL_TEXTURE_2D); bitmap.UnlockBits(bdata); bitmap.Dispose(); Gl.glDeleteTextures(1, handle); y++; } y = 0; x++; } This does draw the whole Quads with their Texture. But cause these are so many, my framerate really crashes. My Bitmaps are about 32 x 32 pixel, and are drawn 30 times to the right, and same to the bottom. Is there a better way to draw the Bitmaps? Maybe I should use a big bitmap to do so? Thanks guys
  5. DJLaitier

    OpenGL draws Texture incorrect

    Yes, that has done the job And i changed the Image-Format, so I choosed a .jpg (no alpha-channel), and now, it´s displaying it very good Thanks
  6. Hey Community I´m trying to display a Quad with a texture, but it´s displaying just some pixels: [media]http://imageshack.us/photo/my-images/21/errorkpl.jpg/[/media] Here´s my code: int x1, x2, y1, y2; public Form1() { x1 = 20; x2 = 100; y1 = 20; y2 = 100; InitializeComponent(); this.simpleOpenGlControl1.InitializeContexts(); const int XSIZE = 640; const int YSIZE = 480; Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); Gl.glOrtho(0, XSIZE, YSIZE, 0, 0, 1); Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glDisable(Gl.GL_DEPTH_TEST); Gl.glClear(Gl.GL_COLOR_BUFFER_BIT); // Texture Bitmap b = new Bitmap(@"C:\Documents and Settings\MartDani\Desktop\menu_button.bmp"); Bitmap bitmap; bitmap = (Bitmap)b.Clone(); // Input bitmap kopieren int m_Width = bitmap.Width; int m_Height = bitmap.Height; int[] handle = new int[1]; Gl.glGenTextures(handle.Length, handle); int m_Handle = handle[0]; handle = null; Rectangle rect = new Rectangle(0, 0, m_Width, m_Height); System.Drawing.Imaging.BitmapData bdata = bitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, bitmap.PixelFormat); Gl.glBindTexture(Gl.GL_TEXTURE_2D, m_Handle); Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, m_Width, m_Height, 0, Gl.GL_RGB, Gl.GL_UNSIGNED_BYTE, bdata.Scan0); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR); Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glTexEnvf(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_DECAL); Gl.glColor3f(1f, 1f, 1f); Gl.glBegin(Gl.GL_QUADS); Gl.glTexCoord2f(x1, y1); Gl.glVertex2f(x1, y1); Gl.glTexCoord2f(x1, y2); Gl.glVertex2f(x1, y2); Gl.glTexCoord2f(x2, y2); Gl.glVertex2f(x2, y2); Gl.glTexCoord2f(x2, y1); Gl.glVertex2f(x2, y1); Gl.glEnd(); Gl.glDisable(Gl.GL_TEXTURE_2D); bitmap.UnlockBits(bdata); bitmap.Dispose(); // // Point Gl.glBegin(Gl.GL_POINTS); Gl.glVertex2f(5, 5); Gl.glEnd(); // /Point // Quad Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glBegin(Gl.GL_QUADS); Gl.glColor3f(1, 0, 0); Gl.glVertex2f(x1 + 100, y1 + 100); Gl.glVertex2f(x2 + 100, y1 + 100); Gl.glVertex2f(x2 + 100, y2 + 100); Gl.glVertex2f(x1 + 100, y2 + 100); Gl.glEnd(); // /Quad } I hope, anyone Can help me Greetings from Germany
  • 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!