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 7080265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:46:26+00:00 2026-05-28T06:46:26+00:00

I’m trying to port some OpenGL rendering code I wrote for iOS to a

  • 0

I’m trying to port some OpenGL rendering code I wrote for iOS to a Windows app. The code runs fine on iOS, but on Windows it doesn’t draw anything. I’ve narrowed the problem down to this bit of code as fixed function stuff (such as glutSolidTorus) draws fine, but when shaders are enabled, nothing works.

Here’s the rendering code:

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_INDEX_ARRAY);

// Set the vertex buffer as current
this->vertexBuffer->MakeActive();

// Get a reference to the vertex description to save copying
const AT::Model::VertexDescription & vd = this->vertexBuffer->GetVertexDescription();

std::vector<GLuint> handles;

// Loop over the vertex descriptions
for (int i = 0, stride = 0; i < vd.size(); ++i)
{
    // Get a handle to the vertex attribute on the shader object using the name of the current vertex description
    GLint handle = shader.GetAttributeHandle(vd[i].first);

    // If the handle is not an OpenGL 'Does not exist' handle
    if (handle != -1)
    {
        glEnableVertexAttribArray(handle);
        handles.push_back(handle);

        // Set the pointer to the vertex attribute, with the vertex's element count,
        // the size of a single vertex and the start position of the first attribute in the array
        glVertexAttribPointer(handle, vd[i].second, GL_FLOAT, GL_FALSE, 
                                sizeof(GLfloat) * (this->vertexBuffer->GetSingleVertexLength()), 
                                (GLvoid *)stride);

    }

    // Add to the stride value with the size of the number of floats the vertex attr uses
    stride += sizeof(GLfloat) * (vd[i].second);
}

// Draw the indexed elements using the current vertex buffer
glDrawElements(GL_TRIANGLES, 
               this->vertexBuffer->GetIndexArrayLength(), 
               GL_UNSIGNED_SHORT, 0);

glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_INDEX_ARRAY);


// Disable the vertexattributearrays
for (int i = 0, stride = 0; i < handles.size(); ++i)
{
    glDisableVertexAttribArray(handles[i]);
}

It’s inside a function that takes a shader as a parameter, and the vertex description is a list of pairs: attribute handles to number of elements. Uniforms are being set outside this function. I’m enabling the shader for use before it’s passed in to the function. Here are the two shader sources:

Vertex:

attribute vec3 position;
attribute vec2 texCoord;
attribute vec3 normal;

// Uniforms

uniform mat4 Model;
uniform mat4 View;
uniform mat4 Projection;
uniform mat3 NormalMatrix;


/// OUTPUTS

varying vec2 o_texCoords;
varying vec3 o_normals;

// Vertex Shader

void main()
{
    // Do the normal position transform
    gl_Position = Projection * View * Model * vec4(position, 1.0);

    // Transform the normals to world space
    o_normals = NormalMatrix * normal;

    // Pass texture coords on for interpolation
    o_texCoords = texCoord;
}

Fragment:

varying vec2 o_texCoords;
varying vec3 o_normals;

/// Fragment Shader

void main()
{
    gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
}

I’m running OpenGL 2.1 with Shader language 1.2. I’d be most appreciative for any help anyone can give me.

  • 1 1 Answer
  • 0 Views
  • 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. Editorial Team
    Editorial Team
    2026-05-28T06:46:27+00:00Added an answer on May 28, 2026 at 6:46 am

    I came back to this recently and it seems that I wasn’t checking for errors during rendering, it was giving me a 1285 error GL_OUT_OF_MEMORY after calling glDrawElements(). This lead me to check the vertex buffer objects to see if they contained any data and it turns out I wasn’t properly deep copying them in a wrapper class, and as a result they were being deleted before any rendering happened. Fixing this sorted the issue.

    Thank you for your suggestions.

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

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.