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

  • Home
  • SEARCH
  • 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 7086467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:33:11+00:00 2026-05-28T07:33:11+00:00

I followed this tutorial and I’m currently trying to create a class to draw

  • 0

I followed this tutorial and I’m currently trying to create a class to draw cubes. The class populates the buffers in a function called setup and draws them in a function called draw.

There are no errors however nothing is displayed on the screen.

My question is basicly how do I go about making a class from which I can render cubes.

Using Xcode 4.2, Opengl and Objective-C.

[edit]

-(void)SetShader:(GLuint)InShader
{
glUseProgram(InShader);

_positionSlot = glGetAttribLocation(InShader, "Position");
_colorSlot = glGetAttribLocation(InShader, "SourceColor");
glEnableVertexAttribArray(_positionSlot);
glEnableVertexAttribArray(_colorSlot);

_projectionUniform = glGetUniformLocation(InShader, "Projection");
_modelViewUniform = glGetUniformLocation(InShader, "Modelview");

_texCoordSlot = glGetAttribLocation(InShader, "TexCoordIn");
glEnableVertexAttribArray(_texCoordSlot);
_textureUniform = glGetUniformLocation(InShader, "Texture");  
}

-(void)SetupVBO
{
    GLuint vertexBuffer;
    glGenBuffers(1, &vertexBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(CubeVertices), CubeVertices, GL_STATIC_DRAW);

    GLuint indexBuffer;
    glGenBuffers(1, &indexBuffer);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(CubeIndices), CubeIndices, GL_STATIC_DRAW);
}

-(void)draw
{
glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
glVertexAttribPointer(_colorSlot, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*) (sizeof(float) * 3));

glVertexAttribPointer(_texCoordSlot, 2, GL_FLOAT, GL_FALSE, 
                      sizeof(Vertex), (GLvoid*) (sizeof(float) * 7));    

glDrawElements(GL_TRIANGLES, sizeof(CubeIndices)/sizeof(CubeIndices[0]), GL_UNSIGNED_BYTE, 0);  
}

-(void)render:(CADisplayLink*)displayLink 
{
glClearColor(0, 0, 0.2, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);

CC3GLMatrix *projection = [CC3GLMatrix matrix];
float h = 4.0f * self.frame.size.height / self.frame.size.width;
[projection populateFromFrustumLeft:-2 andRight:2 andBottom:-h/2 andTop:h/2 andNear:4 andFar:10];
glUniformMatrix4fv(_projectionUniform, 1, 0, projection.glMatrix);

CC3GLMatrix *modelView = [CC3GLMatrix matrix];
[modelView populateFromTranslation:CC3VectorMake(0, 0, -7)];
[modelView translateBy:CC3VectorMake(0,5,0)];
glUniformMatrix4fv(_modelViewUniform, 1, 0, modelView.glMatrix);

glViewport(0, 0, self.frame.size.width, self.frame.size.height);

[m_cube draw];

[_context presentRenderbuffer:GL_RENDERBUFFER];
}
  • 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-28T07:33:12+00:00Added an answer on May 28, 2026 at 7:33 am

    It was as mentioned a problem with the arrangement of my viewport and perspective setups.

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

Sidebar

Related Questions

I am currently trying to develop a GAE application. I followed this tutorial in
I have followed this tutorial which allowed me to create a Silverlight DataGrid that
I'm building an ogre3d tutorial based on this setup http://www.ogre3d.org/wiki/index.php/SettingUpAnApplication#XCode I've followed all steps
I followed this tutorial to setup SVN on my Fedora box http://www.ashishkulkarni.com/installing-subversion-on-fedora-linux/ It worked.
I followed this tutorial to create a popup bar (similar to the one at
I have followed this tutorial to create a seek bar on a transparent background.
I followed this tutorial in order to create a jQuery Horizontal Accordion. It works
I'd like to create a sidebar gadget in Vista. I've followed this tutorial on
I followed this tutorial exactly and received the following error after trying to upload
I followed this tutorial to create multilingual site. http://nuts-and-bolts-of-cakephp.com/2008/11/28/cakephp-url-based-language-switching-for-i18n-and-l10n-internationalization-and-localization/ However although I can get

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.