为什么在atio6axx中会有访问冲突。glBindBuffer dll时打电话?

时间:2022-08-22 23:17:23

Leading up to the problem:

Learning about OpenGL using C, by making a (supposedly easy) tile-based game of my own design. Originally I was drawing only ~10 triangles or so for testing, and I set up the buffer data and indices like so:

学习OpenGL使用C,通过做一个(应该是简单的)基于我自己设计的游戏。最初我只画了大约10个三角形用于测试,我设置了缓冲数据和索引,比如:

const float vertexPositions[] = {
      -1.0f, -0.8f, //0
      -1.0f, -1.0f, //1

      -0.8f, -0.8f, //2
      -0.8f, -1.0f, //3

      -0.8f, -0.8f, //2
      -0.8f, -1.0f, //3

      -0.6f, -0.8f, //4
      -0.6f, -1.0f, //5

      -0.6f, -0.8f, //4
      -0.6f, -1.0f, //5

      -0.4f, -0.8f, //6
      -0.4f, -1.0f, //7

      -0.4f, -0.8f, //6
      -0.4f, -1.0f, //7

      -0.2f, -0.8f, //8
      -0.2f, -1.0f, //9

      -0.2f, -0.8f, //8
      -0.2f, -1.0f, //9

       0.0f, -0.8f, //10
       0.0f, -1.0f, //11

       0.0f, -0.8f, //10
       0.0f, -1.0f, //11

/////////////////////////////////// Texture coords:
       0.0f,  1.0f, //0
       0.0f,  0.0f, //1

       1.0f,  1.0f, //2
       1.0f,  0.0f, //3

       0.0f,  1.0f, //2
       0.0f,  0.0f, //3

       1.0f,  1.0f, //4
       1.0f,  0.0f, //5

       0.0f,  1.0f, //4
       0.0f,  0.0f, //5

       1.0f,  1.0f, //6
       1.0f,  0.0f, //7

       0.0f,  1.0f, //6
       0.0f,  0.0f, //7

       1.0f,  1.0f, //8
       1.0f,  0.0f, //9

       0.0f,  1.0f, //8
       0.0f,  0.0f, //9

       1.0f,  1.0f, //10
       1.0f,  0.0f, //11

       0.0f,  1.0f, //10
       0.0f,  0.0f, //11

const GLubyte indices[] = {
      0, 1, 2, 
      3, 2, 1,

      4, 5, 6,
      7, 6, 5, 

      8, 9, 10,
      11, 10, 9,

      12, 13, 14,
      15, 14, 13,

      16, 17, 18,
      19, 18, 17,
};

Since I would need a lot more triangles to make more triangles, I decided to automate it (also, the values are in pixels instead of screen/viewport co-ordinates as i intend to use some matrices in my shader):

因为我需要更多的三角形来制作更多的三角形,所以我决定将它自动化(同样,当我打算在我的着色器中使用一些矩阵时,这些值是像素而不是屏幕/viewport坐标):

float vertexPositions[6400]; //Declared globally outside the function

int blah()
{
      int count = 0, texture_start;



      for (int y = 0; y < 20; y++)
      {
            for (int x = 0; x < 21; x++)
            {
                  vertexPositions[count++] = x * 32.0f;
                  vertexPositions[count++] = (y + 1) * 32.0f;

                  vertexPositions[count++] = x * 32.0f;                  
                  vertexPositions[count++] = y * 32.0f;

                  if (x > 0 && x < 20)
                  {
                        vertexPositions[count++] = x * 32.0f;
                        vertexPositions[count++] = (y + 1) * 32.0f;

                        vertexPositions[count++] = x * 32.0f;                  
                        vertexPositions[count++] = y * 32.0f;
                  }
            }
      }

      texture_start = count;

      for (int z = 0; z < 400; z++)
      {
                  vertexPositions[count++] = 0.0f;
                  vertexPositions[count++] = 1.0f;

                  vertexPositions[count++] = 0.0f;
                  vertexPositions[count++] = 0.0f;

                  vertexPositions[count++] = 1.0f;
                  vertexPositions[count++] = 1.0f;

                  vertexPositions[count++] = 1.0f;
                  vertexPositions[count++] = 0.0f;
      }

      return 0;
}

Note, I haven't automated the indices because I wanted to make sure I could get the exact same triangles from this new data.

注意,我没有自动执行索引,因为我想确保能从这个新数据中得到完全相同的三角形。

The Issue:

I repeatedly get access violations on certain GL calls. If I step manually between breakpoints it always fails when it reaches glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, positionBufferObject);.

我在某些GL调用中多次访问违规。如果我在断点之间手动操作,当它到达glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, positionBufferObject)时,它总是失败。

If I have one breakpoint on this line and one breakpoint after this line it skips(ignores? silently fails on?) the lines in between and breaks when it reaches GLuint fShader = glCreateShader(GL_FRAGMENT_SHADER); inside the myProgram = CreateProgram(); call (which is surprising since my vertex shader is created immediately previous with an identical call and works fine).

如果在这条线上有一个断点,在这条线之后有一个断点,它就会跳过(忽略?当它到达GLuint fShader = glCreateShader(GL_FRAGMENT_SHADER)时,在中间的线和中断之间的线就会消失;在myProgram = CreateProgram()中;调用(这是令人惊讶的,因为我的顶点着色器是在一个相同的调用之前创建的,并且运行良好)。

GLvoid InitGL(GLvoid)
{
      blah(); <----where i initialize my vertex data
      FnLdInit();
      GetBitmap();

      //char * glVer = (char *)glGetString(GL_VERSION);
      //char * glSLV = (char *)glGetString(GL_SHADING_LANGUAGE_VERSION);

      glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
      glClearDepth(1.0f);
      glEnable(GL_DEPTH_TEST);
      glDepthFunc(GL_LEQUAL);      ---------------------------//~BREAKPOINT HERE!~

      glGenBuffers(1, &positionBufferObject);
      errort = glGetError();

      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, positionBufferObject); 
      //errort = glGetError();
      glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(vertexPositions), (const float *)vertexPositions, GL_STATIC_DRAW);
      //errort = glGetError();
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
      //errort = glGetError();

      myProgram = CreateProgram();   -------------------------//~BREAKPOINT HERE!~

}

All glGetError()'s return 0, which the spec says it means: there is no problem or glGetError had its own error.

所有glge恐怖()的返回0,规范说它的意思是:没有问题或glge恐怖有它自己的错误。

No matter where it breaks though, the call stack pelles C shows me when it breaks is 'atio6axx.dll; DrvPresentBuffers() +163B7B' and it is always here:

不管它在哪里断开,调用堆栈pelles C显示当它断开时是'atio6axx.dll;drvpresentbuffer () +163B7B,它总是在这里:

为什么在atio6axx中会有访问冲突。glBindBuffer dll时打电话?

I recently installed the latest Catalyst update for my Radeon HD 6850. I can find nothing regarding memory limitations in regards to the GPU/vertex buffer objects/etc, and I doubt ~25KB of data would break much of anything at all. I have a feeling it's not an OpenGL issue, and rather something in the way I'm implementing my code or a limitation/memory issue I'm unfamiliar with.

我最近安装了我的Radeon 6850最新的催化剂更新。对于GPU/顶点缓冲对象/etc,我没有任何关于内存限制的东西,我怀疑~25KB的数据将会破坏任何东西。我有一种感觉,这不是OpenGL的问题,而是我正在实现代码的方式,或者是我不熟悉的限制/内存问题。

Poster #20 on this site has a similar problem, but it seems to be connected to a program failure, not code (and I think it happened before the latest drivers came out, even though it was posted Oct 11th). GetBitmap() makes use of glBindTexture and other calls with no problems.

这个网站上的20号海报也有类似的问题,但它似乎是连接到一个程序故障,而不是代码(我认为它发生在最新的驱动程序出现之前,尽管它是在10月11日发布的)。GetBitmap()使用glbind纹理和其他没有问题的调用。

This seems like the most obvious, but the only thing I changed from my old algorithm to my new is the automation of my data creation. There are no pointers involved, and I even cast to a const float *, which the compiler didn't even warn me was necessary.

这似乎是最明显的,但是我从旧的算法改变到我的新算法的唯一的东西就是我的数据创建的自动化。这里没有涉及的指针,我甚至把它投到一个const float *中,编译器甚至没有警告我这是必要的。

Am I looking in the wrong places for the solution to a simple problem? I'll try to explain my code/add more of it if needed, just ask. I'd really rather not write out ~6400 values or more by hand.

我是否在错误的地方寻找解决简单问题的方法?如果需要,我会试着解释我的代码/添加更多的代码。我真的不愿意用手工写出~6400个值。

Edit #1: After some other tests it seems this error occurs even with the old implementation. I must not have compiled it for a while (been working on the shaders, which are separate files). I am very confused.

编辑#1:在一些其他测试之后,即使旧的实现也会出现这个错误。我不应该在一段时间内编译它(一直在处理阴影,这是单独的文件)。我很困惑。

Edit #2: Some more code. This is the only function that occurs before InitGL, and is the one that calls InitGl. :

编辑#2:一些代码。这是在InitGL之前发生的唯一函数,是调用InitGL的函数。:

bool CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
{
      GLuint PixelFormat;
      WNDCLASS wc;
      DWORD dwExStyle;
      DWORD dwStyle;

      RECT WindowRect;
      WindowRect.left = (long)0;
      WindowRect.right = (long)width;
      WindowRect.top = (long)0;
      WindowRect.bottom = (long)height;

      fullscreen = fullscreenflag;

      hInstance = GetModuleHandle(NULL);

      wc.style = CS_HREDRAW |CS_VREDRAW | CS_OWNDC;
      wc.lpfnWndProc = (WNDPROC) WndProc;
      wc.cbClsExtra = 0;
      wc.cbWndExtra = 0;
      wc.hInstance = hInstance;
      wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
      wc.hCursor = LoadCursor(NULL, IDC_ARROW);
      wc.hbrBackground = NULL;
      wc.lpszMenuName = NULL;
      wc.lpszClassName = "OpenGL";

      if (!RegisterClass(&wc))
      {
            MessageBox(NULL, "Failed to register the window class", "Error", MB_OK | MB_ICONEXCLAMATION);

            return FALSE;
      }

      if (fullscreen)
      {
            int changeresult;
            //char msg[100];
            DISPLAY_DEVICE disp;
            DEVMODE dmScreenSettings;
            int dw;

            memset(&disp, 0, sizeof(disp));
            memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));

            disp.cb = sizeof(disp);


            if (!(EnumDisplayDevices(NULL, 0, &disp, 0)))
            {
                  return 1;
            }


            dmScreenSettings.dmSize = sizeof(dmScreenSettings);

            //ENUM_CURRENT_SETTINGS
            if (!(EnumDisplaySettings(disp.DeviceName, ENUM_CURRENT_SETTINGS, &dmScreenSettings)))
            {
                  dw = GetLastError();
            }

            dmScreenSettings.dmPelsWidth = width; //enable this in real
            dmScreenSettings.dmPelsHeight = height; //enable this in real

            changeresult = ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);

            //dmScreenSettings.dmPelsWidth = width;
            //dmScreenSettings.dmPelsHeight = height;
            //dmScreenSettings.dmBitsPerPel = bits;
            dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

            if (changeresult != DISP_CHANGE_SUCCESSFUL)
            {
                  if (MessageBox(NULL, "Use window mode?", "GL", MB_YESNO | MB_ICONEXCLAMATION) == IDYES)
                  {
                        fullscreen = FALSE;
                  }
                  else
                  {
                        return FALSE;
                  }
            }
      }

      if (fullscreen)
      {
            dwExStyle = WS_EX_APPWINDOW;
            dwStyle = WS_POPUP;
            ShowCursor(FALSE);
      }
      else
      {
            dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
            dwStyle = WS_OVERLAPPEDWINDOW;
      }

      AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);

      if(!(hWnd = CreateWindowEx(   dwExStyle,
                                    "OpenGL",
                                    title,
                                    WS_CLIPSIBLINGS | WS_CLIPCHILDREN | dwStyle,
                                    0,
                                    0,
                                    WindowRect.right - WindowRect.left,
                                    WindowRect.bottom - WindowRect.top,
                                    NULL,
                                    NULL,
                                    hInstance,
                                    NULL)))
      {
            KillGLWindow();
            MessageBox(NULL, "Window Creation error", "Error", MB_OK | MB_ICONEXCLAMATION);

            return FALSE;
      }

      static  PIXELFORMATDESCRIPTOR pfd=                  // pfd Tells Windows How We Want Things To Be
      {
          sizeof(PIXELFORMATDESCRIPTOR),                  // Size Of This Pixel Format Descriptor
          1,                              // Version Number
          PFD_DRAW_TO_WINDOW |            // Format Must Support Window
          PFD_SUPPORT_OPENGL |            // Format Must Support OpenGL
          PFD_DOUBLEBUFFER,               // Must Support Double Buffering
          PFD_TYPE_RGBA,                  // Request An RGBA Format
          0,                           // Select Our Color Depth
          0, 0, 0, 0, 0, 0,               // Color Bits Ignored
          0,                              // No Alpha Buffer
          0,                              // Shift Bit Ignored
          0,                              // No Accumulation Buffer
          0, 0, 0, 0,                     // Accumulation Bits Ignored
          16,                             // 16Bit Z-Buffer (Depth Buffer)
          0,                              // No Stencil Buffer
          0,                              // No Auxiliary Buffer
          PFD_MAIN_PLANE,                 // Main Drawing Layer
          0,                              // Reserved
          0, 0, 0                         // Layer Masks Ignored
      };
      pfd.cColorBits = bits;

      if (!(hDC = GetDC(hWnd)))
      {
            KillGLWindow();
            MessageBox(NULL, "Can't create a GL device context", "Error", MB_OK | MB_ICONEXCLAMATION);

            return FALSE;
      }

      if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd)))
      {
            KillGLWindow();
            MessageBox(NULL, "Can't find a suitable pixelformat", "Error", MB_OK | MB_ICONEXCLAMATION);

            return FALSE;
      }

      if (!SetPixelFormat(hDC, PixelFormat, &pfd))
      {
            KillGLWindow();
            MessageBox(NULL, "Can't set the pixel format", "Error", MB_OK | MB_ICONEXCLAMATION);

            return FALSE;
      }

      if (!(hRC = wglCreateContext(hDC)))
      {
            KillGLWindow();
            MessageBox(NULL, "Can't create a GL rendering context", "Error", MB_OK | MB_ICONEXCLAMATION);

            return FALSE;
      }

      if (!wglMakeCurrent(hDC, hRC))
      {
            KillGLWindow();
            MessageBox(NULL, "Can't activate the GL rendering context", "Error", MB_OK | MB_ICONEXCLAMATION);

            return FALSE;
      }

      ShowWindow(hWnd, SW_SHOW);
      SetForegroundWindow(hWnd);
      SetFocus(hWnd);

      InitGL();
      ResizeGLScene(width, height);

      //char * glVer = (char *)glGetString(GL_VERSION);
      //char * glSLV = (char *)glGetString(GL_SHADING_LANGUAGE_VERSION);

      return TRUE;
}

FnLdInit is where I hook up all the extensions:

FnLdInit是我连接所有扩展的地方:

void FnLdInit(void)
{
      HINSTANCE hGLLIB = NULL;
      hGLLIB = LoadLibrary("opengl32.dll");

      glActiveTexture                     = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTexture");
      glAttachShader                      = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader");
      glBindBuffer                        = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer");
      glBufferData                        = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData");
      glCompileShader                     = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader");
      glCreateProgram                     = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram");
      glCreateShader                      = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader");
      glDeleteShader                      = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader");
      glDetachShader                      = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader");
      glDisableVertexAttribArray          = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray");
      glEnableVertexAttribArray           = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray");
      glGenBuffers                        = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers");
      glGetShaderInfoLog                  = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog");
      glGetShaderiv                       = (PFNGLGETSHADERIVPROC)wglGetProcAddress("glGetShaderiv");
      glGetUniformfv                      = (PFNGLGETUNIFORMFVPROC)wglGetProcAddress("glGetUniformfv");
      glGetUniformLocation                = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation");
      glLinkProgram                       = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram");
      glShaderSource                      = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource");
      glUniform1i                         = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i");
      glUniform2f                         = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f");
      glUseProgram                        = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram");
      glVertexAttribPointer               = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer");

      glBindTexture           = (PFNGLBINDTEXTUREPROC)GetProcAddress(hGLLIB, "glBindTexture");
      glClear                 = (PFNGLCLEARPROC)GetProcAddress(hGLLIB, "glClear");
      glClearColor            = (PFNGLCLEARCOLORPROC)GetProcAddress(hGLLIB, "glClearColor");
      glClearDepth            = (PFNGLCLEARDEPTHPROC)GetProcAddress(hGLLIB, "glClearDepth");
      glDepthFunc             = (PFNGLDEPTHFUNCPROC)GetProcAddress(hGLLIB, "glDepthFunc");
      glDrawArrays            = (PFNGLDRAWARRAYSPROC)GetProcAddress(hGLLIB, "glDrawArrays");
      glEnable                = (PFNGLENABLEPROC)GetProcAddress(hGLLIB, "glEnable");
      glGenTextures           = (PFNGLGENTEXTURESPROC)GetProcAddress(hGLLIB, "glGenTextures");
      glTexImage2D            = (PFNGLTEXIMAGE2DPROC)GetProcAddress(hGLLIB, "glTexImage2D");
      glTexParameteri         = (PFNGLTEXPARAMETERIPROC)GetProcAddress(hGLLIB, "glTexParameteri");
      glViewport              = (PFNGLVIEWPORTPROC)GetProcAddress(hGLLIB, "glViewport");
      glDrawElements          = (PFNGLDRAWELEMENTSPROC)GetProcAddress(hGLLIB, "glDrawElements");
      glGetError              = (PFNGLGETERRORPROC)GetProcAddress(hGLLIB, "glGetError");
      glGetString             = (PFNGLGETSTRINGPROC)GetProcAddress(hGLLIB, "glGetString");
}

And here's GetBitmap():

这里是GetBitmap():

int GetBitmap(void)
{
      char        * bmBuffer, * pxPtr;
      FILE        * bmFile;
      //FILE * result;
      GLuint      texture;

      int         bmSize, 
                  dataOffset, 
                  dibSize, 
                  bmWidthPx, 
                  bmHeightPx,
                  bmCompression,
                  dataSize,
                  dataHorRes,
                  dataVerRes,
                  paletteNumClrs,
                  importantClrs,

                  bmBytesPerPixel = 3, //Default -> RGB

                  totalBytesPerRow,
                  pixelBytesPerRow,
                  padCount = 0;

      short int   bmClrPlane, bmBPP;
      char        bmChar0, bmChar1;
      //char msgData[100];

      bmFile = fopen("multisquare.bmp", "rb");
      if (bmFile == NULL)
      {
            return 1;
      }

      bmChar0 = fgetc(bmFile);
      bmChar1 = fgetc(bmFile);
      if (bmChar0 != 'B' || bmChar1 != 'M')
      {
            return 2;
      }

      //sprintf(msgData, "%c%c", bmChar0, bmChar1);
      //MessageBox(NULL, msgData, NULL, MB_OK | MB_ICONINFORMATION);

      bmSize = Get4Bytes(bmFile);

      //Skip 4 bytes. These bytes are application specific,
      //and generally unused.
      if (fseek(bmFile, 4, SEEK_CUR) != 0)
      {
            return 3;
      }

      dataOffset = Get4Bytes(bmFile);

      dibSize = Get4Bytes(bmFile);

      //Replace 'if dibSize' check with case statement
      //which branches to functions for different sized 
      //DIBHeaders.
      //
      //
      if (dibSize != 40)
      {
            return 4;
      }

      bmWidthPx = Get4Bytes(bmFile);
      bmHeightPx = Get4Bytes(bmFile); //Later -> handle negative = top->bottom.

      bmClrPlane = Get2Bytes(bmFile); //Must always be 1 anyways, consider removing this and skipping 2 bytes.
      bmBPP = Get2Bytes(bmFile);

      if (bmBPP == 24)
      {
            bmBytesPerPixel = 3;
      }

      bmCompression = Get4Bytes(bmFile);
      //Handle other compressions at some later time.
      if (bmCompression != 0)
      {
            return 5;
      }

      //Can use this to allocate appropriate memory space.
      dataSize = Get4Bytes(bmFile);

      //Resolutions doesn't seem too important atm.
      dataHorRes = Get4Bytes(bmFile);
      dataVerRes = Get4Bytes(bmFile);

      //Will probably both be 0. Irrelevant atm.
      paletteNumClrs = Get4Bytes(bmFile);
      importantClrs = Get4Bytes(bmFile);

      bmBuffer = (char *) calloc(dataSize, sizeof(char)); //Space allocated.

      fseek(bmFile, dataOffset, SEEK_SET);

      //Ex: 10 pixels * 3 bytes/pixel = 30 bytes
      //    30 + 3 = 33 -> 0010 0001
      //    Right shift 2: 0000 1000  -> These operations round to nearest
      //    Shift left 2:  0010 0000  -> multiple of 4.
      //    32 bytes to reach 4byte multiple
      //    So 30 bytes for 10 pixles plus 2 extra bytes of padding, per row.
      pixelBytesPerRow = bmWidthPx * bmBytesPerPixel;
      totalBytesPerRow = ((pixelBytesPerRow + bmBytesPerPixel) >> 2) << 2;
      padCount = totalBytesPerRow - pixelBytesPerRow;

      pxPtr = bmBuffer;

      switch(padCount)
      {
            case 0:
            {
                  for (int A = 0; A <= bmHeightPx; A++)
                  {
                        /*
                        for (int B = 0; B <= bmWidthPx; B++)
                        {

                              *(pxPtr + 2) = fgetc(bmFile);
                              *(pxPtr + 1) = fgetc(bmFile);
                              *pxPtr       = fgetc(bmFile);

                        }
                        */
                        fread(pxPtr, 1, pixelBytesPerRow, bmFile);
                        pxPtr += totalBytesPerRow;
                  }

                  break;
            }
            case 1:
            case 2:
            case 3:
            {
                  for (int A = 0; A <= bmHeightPx; A++)
                  {
                        /*
                        for (int B = 0; B <= bmWidthPx; B++)
                        {

                              *(pxPtr + 2) = fgetc(bmFile);
                              *(pxPtr + 1) = fgetc(bmFile);
                              *pxPtr       = fgetc(bmFile);

                        }
                        */
                        fread(pxPtr, 1, pixelBytesPerRow, bmFile);

                        if (fseek(bmFile, padCount, SEEK_CUR) != 0)
                        {
                              return 3;
                        }

                        pxPtr += totalBytesPerRow;

                  }

                  break;
            }
            default:
            //Shouldn't get here
            break;
      }
      //result = fopen("test.txt","w");
      //fwrite(bmBuffer, 1, dataSize , result);
      //fclose(result);
      fclose(bmFile);

      glActiveTexture(GL_TEXTURE0);
      glGenTextures(1, &texture);
      glBindTexture(GL_TEXTURE_2D, texture);

      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

      glTexImage2D(GL_TEXTURE_2D,   /*Type of texture*/
                   0,               /*Level of Detail number*/
                   GL_RGB,          /*Internal format*/
                   bmWidthPx,       /*Width in texels(pixels?)*/
                   bmHeightPx,      /*Height in texels(pixels?)*/
                   0,               /*Border. Must be 0 (probably only for 2D)*/
                   GL_BGR,          /*Format, of the data the texture will be created from*/
                   GL_UNSIGNED_BYTE,/*Data type of the pixel data*/
                   bmBuffer);       /*Pointer to the image data to create the texture from*/

      //glBindTexture(GL_TEXTURE_2D, 0);

      free(bmBuffer);


      return 0;
}

Edit #3: Unistalled Catalyst 12.10 and all associated drivers. Reinstalled 12.8. Same problem, but now it happens on GenBuffers. Odd.

编辑#3:uni停滞的Catalyst 12.10和所有相关的驱动程序。重新安装12.8。同样的问题,但现在它发生在genbuffer上。奇数。

Edit #4: I tried making my project 32bit, and compiling it. I get the exact same problem, though for some reason Pelles C is not labeling the LIBs (it just says "untitled" anytime it mentions one) so I can only assume the 32bit lib AMD provides is also failing (as atio6axx.dll/.lib is not loaded). I have a feeling this problem won't have any real solution because it seems to stem from the drivers, not my code. After searching and seeing related problems like this, it seems like there isn't really a client-side solution.

编辑#4:我试着让我的项目32位,并编译它。我得到了完全相同的问题,尽管由于某些原因,Pelles C并没有给LIBs贴上标签(它只是在提到一个时才说“untitled”),所以我只能假设lib AMD提供的32位也失败了(作为atio6axx.dll/)。*不是加载)。我有一种感觉,这个问题不会有任何真正的解决方案,因为它似乎来自于驱动程序,而不是我的代码。在搜索和查看类似的问题之后,似乎并没有真正的客户端解决方案。

Edit #5: Another issue, which I did not notice before because the program never gave me an access violation at this point, is that the code will reach glActiveTexture(GL_TEXTURE0); and suddenly skip all the lines afterwords and exits the function. By removing this line the next lines are executed. glActiveTexture(GL_TEXTURE0); is from atio6axx.dll while all the other commands are from OPENGL32.dll, so it seems to have narrowed it down. What's odd is there is no access violation at this point, just the odd skipping.

编辑#5:另一个问题,我之前没有注意到,因为这个程序在这一点上从来没有给我一个访问权限,这是代码将会到达glActiveTexture(GL_TEXTURE0);然后突然跳过所有的行尾词并退出功能。通过删除这一行,下一行将被执行。glActiveTexture(GL_TEXTURE0);来自atio6axx。所有其他命令都来自OPENGL32。dll,它似乎已经缩小了。奇怪的是在这一点上没有访问违背,只是奇怪的跳跃。

I suppose no one can see a reason for any of this happening? I've even installed the beta Catalyst drivers, which has a version atio6axx.dll that is dated 15\11\2012 (last thursday). So up-to-date drivers are not an issue. I've even tried every driver version since Catalyst 12.4 (current is 12.10, and this program ran with 12.8). At a loss, and even a new program runs into the same problems.

我想没有人能看出其中的原因吧?我甚至已经安装了beta催化剂驱动程序,它有一个版本atio6axx。dll,日期为15\11\2012(上星期四)。所以最新的驱动程序不是问题。我甚至尝试过每个驱动版本,因为Catalyst 12.4(当前是12.10,这个程序是12.8)。在一个损失中,甚至一个新的程序也会遇到同样的问题。

1 个解决方案

#1


2  

The code for the vertex positions seems good and does not appear to write outside the bounds of the array. The access violation you see is probably caused by r11 being invalid. OpenGL driver code is usually multithreaded so it might be possible that you only see that error when a worker thread tries to access that bad buffer. Which could account for the strange behavior you are seeing in the locality of the failure.

顶点位置的代码看起来很好,并且似乎没有在数组的边界之外写入。您所看到的访问冲突可能是由r11造成的。OpenGL驱动程序代码通常是多线程的,所以当一个工作线程试图访问那个坏缓冲区时,您可能只看到这个错误。这可以解释你在失败的地方看到的奇怪的行为。

Make sure that the buffer is not freed before the GPU is done with it, that you pass the proper sizes, etc.

确保在GPU完成之前,缓冲区没有被释放,您可以通过适当的大小,等等。

I'm afraid you'll have to paste more code for us to be able to assist you further.

恐怕你得给我们贴上更多的代码才能进一步帮助你。

Also providing us with the value of r11 might help.

另外,提供r11的价值可能会有所帮助。

#1


2  

The code for the vertex positions seems good and does not appear to write outside the bounds of the array. The access violation you see is probably caused by r11 being invalid. OpenGL driver code is usually multithreaded so it might be possible that you only see that error when a worker thread tries to access that bad buffer. Which could account for the strange behavior you are seeing in the locality of the failure.

顶点位置的代码看起来很好,并且似乎没有在数组的边界之外写入。您所看到的访问冲突可能是由r11造成的。OpenGL驱动程序代码通常是多线程的,所以当一个工作线程试图访问那个坏缓冲区时,您可能只看到这个错误。这可以解释你在失败的地方看到的奇怪的行为。

Make sure that the buffer is not freed before the GPU is done with it, that you pass the proper sizes, etc.

确保在GPU完成之前,缓冲区没有被释放,您可以通过适当的大小,等等。

I'm afraid you'll have to paste more code for us to be able to assist you further.

恐怕你得给我们贴上更多的代码才能进一步帮助你。

Also providing us with the value of r11 might help.

另外,提供r11的价值可能会有所帮助。