Note that there are some explanatory texts on larger screens.

plurals
  1. POGL_UNSIGNED_SHORT_5_6_5 undeclared?
    primarykey
    data
    text
    <p>I have a problem loading a texture using SDL library.</p> <p>Usually I make programs on Linux but I try to create a code that is compatible with Visual Studio also. On Linux are everything OK but on Visual Studio it crashes in "GL_UNSIGNED_SHORT_5_6_5" in the glTexImage2D(...) function.</p> <p>Below is a general idea about what i want to do which I inspired by <a href="http://www.youtube.com/watch?v=dxQY02g3I6g" rel="nofollow">this</a> tutorial:</p> <pre><code>#include "stdafx.h" #include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; #include &lt;GL/glut.h&gt; //#include &lt;GL/glext.h&gt; #include "SDL.h" int brick; float c=0.5; float rx_min=0, ry_min=0; float rx_max=1, ry_max=1; unsigned int LoadTexture(const char* filename); void DrawTexture(int object); void setupmywindow(); void myDrawing(); void setupmywindow() { glClearColor(1.0,1.0,1.0,0); glColor3f(0.0, 0.0, 0.0); glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); gluOrtho2D(rx_min,ry_min, rx_max, ry_max); brick = LoadTexture("brick.bmp"); } void DrawTexture(int object) { glBindTexture(GL_TEXTURE_2D, object); glColor3f(c,c,c); glBegin(GL_QUADS); glTexCoord2f(0., 1. ); glVertex2f( rx_min , ry_min ); glTexCoord2f(0., 0. ); glVertex2f( rx_min, ry_max ); glTexCoord2f(1., 0. ); glVertex2f( rx_max , ry_max ); glTexCoord2f(1., 1. ); glVertex2f( rx_max , ry_min ); glEnd(); } unsigned int LoadTexture(const char* filename) { SDL_Surface* img=SDL_LoadBMP(filename); unsigned int id; glGenTextures(1, &amp;id); glBindTexture(GL_TEXTURE_2D,id); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, img-&gt;w, img-&gt;h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, img-&gt;pixels); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); SDL_FreeSurface(img); return id; } void myDrawing() { glClear(GL_COLOR_BUFFER_BIT); DrawTexture(brick); glFlush(); } int main(int argc, char **argv) { printf("AUTH Computational Physics - Computer Graphics\n"); printf("Project &gt;&gt;TestTexture.cpp\n"); printf("--------------------------------------------------------\n"); glutInit(&amp;argc, argv); glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); glutInitWindowPosition(50,50); glutCreateWindow("Texture Test"); setupmywindow(); glutDisplayFunc(myDrawing); glutMainLoop(); return 0; } </code></pre> <p>The error is: </p> <blockquote> <p>error C2065: 'GL_UNSIGNED_SHORT_5_6_5' : undeclared identifier</p> </blockquote> <p><a href="https://dl.dropboxusercontent.com/u/89389295/brick.bmp" rel="nofollow">Here</a> is the image that I try to load and it is configured as a bitmap (8bit 5 6 5) with GIMP 2.8</p> <p><strong>NOTE</strong>: When I uncoment <em>#include &lt; GL/glext.h ></em> which is not needed on Linux, I get the above message: Unhandled exception at 0x00d1193f in testTesxture.exe: 0xC0000005: Access violation reading location 0x00000014.</p> <p>Generally if I save a bitmap image (for example with paint) how can I uderstand the type I have to put (GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_BYTE etc)?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload