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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:00:23+00:00 2026-06-17T03:00:23+00:00

I have written a class that currently allows the loading of 3D Models via

  • 0

I have written a class that currently allows the loading of 3D Models via an array and a variable(specifying the amount of variables in the array). The code seems fine to me but doesn’t draw anything on the screen.

This is the Vertex Struct.

typedef struct
{
    float pos[3];
    float texCoord[2];
    float colour[4];
} Vertex;

This is the how the Model is initialised.

- (id)VModelWithArray:(Vertex[])Vertices count:(unsigned short)count
{
    self.Vertices = Vertices;
    self.count = count;
    return self;
}

The two class variables are declared in the header like so.

@property (nonatomic, assign) Vertex *Vertices;
@property (nonatomic, assign) unsigned short count;

It is called in my view controller like so.

Vertex array[] = {
        {{1, -1, 0}, {1, 0}, {1, 0, 0, 1}},
        {{1, 1, 0}, {1, 1}, {0, 1, 0, 1}},
        {{-1, 1, 0}, {0, 1}, {1, 1, 1, 1}}
    };

    unsigned short elements = sizeof(array)/sizeof(Vertex);
    self.model = [[VModel alloc] VModelWithArray:array count:elements];

The Model class is declared in the header like so.

@property (strong, nonatomic) VModel *model;

The VBOs are created by this method.

- (void)CreateVBO
{
    glGenBuffers(1, &VBO);
    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(Vertex)*self.count, self.Vertices, GL_STATIC_DRAW);
}

It is called after the Model is initialised in the view controller like so.

[self.model CreateVBO];

The Model is rendered by this method.

- (void)Render
{
    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glEnableVertexAttribArray(GLKVertexAttribPosition);
    glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *) offsetof(Vertex, pos));
    glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
    glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *) offsetof(Vertex, texCoord));
    glEnableVertexAttribArray(GLKVertexAttribColor);
    glVertexAttribPointer(GLKVertexAttribColor, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (const GLvoid *) offsetof(Vertex, colour));
    glDrawArrays(GL_TRIANGLES, 0, self.count);
    glDisableVertexAttribArray(GLKVertexAttribPosition);
    glDisableVertexAttribArray(GLKVertexAttribTexCoord0);
    glDisableVertexAttribArray(GLKVertexAttribColor);
}

It is called in this method.

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect 
{
    glClearColor(0.5, 0.5, 0.5, 1.0);
    glClear(GL_COLOR_BUFFER_BIT);
    [self.effect prepareToDraw];
    [self.model Render];
}

Any help would be very much appreciated.

  • 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-06-17T03:00:24+00:00Added an answer on June 17, 2026 at 3:00 am

    I figured it out, I accidentally left out these lines when merging the code from a previous project.

    [EAGLContext setCurrentContext:self.context];
    self.effect = [[GLKBaseEffect alloc] init];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I am re-vamping some code that I currently have written something like this:
I have written a class that will handle internal logging in my application. Now
I have written an apex class that will create a PDF quote and attach
Per a client's request I have written a communication class that inherits from webclient.
I have written a class in python that implements __str__(self) but when I use
I have a class written in C++ that uses also some definitions from cuda_runtime.h,
I have a class that I've written a TypeConverter for. I want to keep
I have the following class written by someone else that I'm trying to understand
I have an application written using C++ Builder 5 that uses the TDocument class.
I have written some extension methods that extend the html helper class for client

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.