Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 117827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:23:52+00:00 2026-05-11T03:23:52+00:00

I’m stuck at not being able to map texture to a square in openGLES.

  • 0

I’m stuck at not being able to map texture to a square in openGLES. I’m trying to display a jpg image on the screen, and in order for me to do that, I draw a square that I want to then map image onto. However all I get as an output is a white square. I don’t know what am I doing wrong. And this problem is preventing me from moving forward with my project. I’m using Managed OpenGL ES wrapper for Windows Mobile. I verified that the texture is loading correctly, but I can’t apply it to my object. I uploaded sample project that shows my problem here. You would need VS2008 with Windows Mobile 6 SDK to be able to run it. I’m also posting the code of the Form that renders and textures an object here. Any suggestions would be much appreciated, since I’ve been stuck on this problem for a while, and I can’t figure out what am I doing wrong.

    public partial class Form1 : Form {     [DllImport('coredll')]     extern static IntPtr GetDC(IntPtr hwnd);      EGLDisplay myDisplay;     EGLSurface mySurface;     EGLContext myContext;      public Form1()     {         InitializeComponent();         myDisplay = egl.GetDisplay(new EGLNativeDisplayType(this));          int major, minor;         egl.Initialize(myDisplay, out major, out minor);          EGLConfig[] configs = new EGLConfig[10];         int[] attribList = new int[]          {              egl.EGL_RED_SIZE, 5,              egl.EGL_GREEN_SIZE, 6,              egl.EGL_BLUE_SIZE, 5,              egl.EGL_DEPTH_SIZE, 16 ,              egl.EGL_SURFACE_TYPE, egl.EGL_WINDOW_BIT,             egl.EGL_STENCIL_SIZE, egl.EGL_DONT_CARE,             egl.EGL_NONE, egl.EGL_NONE          };          int numConfig;         if (!egl.ChooseConfig(myDisplay, attribList, configs, configs.Length, out numConfig) || numConfig < 1)             throw new InvalidOperationException('Unable to choose config.');          EGLConfig config = configs[0];         mySurface = egl.CreateWindowSurface(myDisplay, config, Handle, null);         myContext = egl.CreateContext(myDisplay, config, EGLContext.None, null);          egl.MakeCurrent(myDisplay, mySurface, mySurface, myContext);         gl.ClearColor(0, 0, 0, 0);         InitGL();     }      void InitGL()     {         gl.ShadeModel(gl.GL_SMOOTH);         gl.ClearColor(0.0f, 0.0f, 0.0f, 0.5f);         gl.BlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA);         gl.Hint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST);     }      public unsafe void DrawGLScene()     {         gl.MatrixMode(gl.GL_PROJECTION);         gl.LoadIdentity();         gl.Orthof(0, ClientSize.Width, ClientSize.Height, 0, 0, 1);         gl.Disable(gl.GL_DEPTH_TEST);          gl.MatrixMode(gl.GL_MODELVIEW);         gl.LoadIdentity();          Texture myImage;         Bitmap Image = new Bitmap(@'\Storage Card\Texture.jpg');         using (MemoryStream ms = new MemoryStream())         {             Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);             myImage = Texture.LoadStream(ms, false);         }          float[] rectangle = new float[] {                 0, 0,                 myImage.Width, 0,                 0,  myImage.Height,                 myImage.Width,  myImage.Height             };          float[] texturePosition = new float[] {                 0, 0,                 myImage.Width, 0,                 0,  myImage.Height,                 myImage.Width,  myImage.Height             };          //Bind texture         gl.BindTexture(gl.GL_TEXTURE_2D, myImage.Name);         gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR);         gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR);         gl.EnableClientState(gl.GL_TEXTURE_COORD_ARRAY);         gl.EnableClientState(gl.GL_VERTEX_ARRAY);          //draw square and texture it.         fixed (float* rectanglePointer = &rectangle[0], positionPointer = &texturePosition[0])         {             gl.TexCoordPointer(2, gl.GL_FLOAT, 0, (IntPtr)positionPointer);             gl.VertexPointer(2, gl.GL_FLOAT, 0, (IntPtr)rectanglePointer);             gl.DrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4);         }          gl.DisableClientState(gl.GL_TEXTURE_COORD_ARRAY);         gl.DisableClientState(gl.GL_VERTEX_ARRAY);      }      protected override void OnPaintBackground(PaintEventArgs e)     {      }      protected override void OnPaint(PaintEventArgs e)     {         base.OnPaint(e);         gl.Clear(gl.GL_COLOR_BUFFER_BIT);          DrawGLScene();         egl.SwapBuffers(myDisplay, mySurface);         gl.Clear(gl.GL_COLOR_BUFFER_BIT);     }      protected override void OnClosing(CancelEventArgs e)     {         if (!egl.DestroySurface(myDisplay, mySurface))             throw new Exception('Error while destroying surface.');         if (!egl.DestroyContext(myDisplay, myContext))             throw new Exception('Error while destroying context.');         if (!egl.Terminate(myDisplay))             throw new Exception('Error while terminating display.');         base.OnClosing(e);     } } 
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:23:53+00:00Added an answer on May 11, 2026 at 3:23 am

    You need to enable texturing:

    glEnable( GL_TEXTURE_2D ); 

    before rendering the square.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.