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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:20:36+00:00 2026-06-18T12:20:36+00:00

I need a little help with drawing pixels on screen. The code I have

  • 0

I need a little help with drawing pixels on screen. The code I have written works fine on simulator but when I deploy on device it output garbage. So here’s my code:

I have GLKViewController setup and here’s the viewDidLoad:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];

    if (!self.context) {
        NSLog(@"Failed to create ES context");
    }

    GLKView *view = (GLKView *)self.view;
    view.context = self.context;
    view.drawableDepthFormat = GLKViewDrawableDepthFormat24;

    [EAGLContext setCurrentContext:self.context];

    self.effect = [[GLKBaseEffect alloc] init];


    self.effect.useConstantColor = GL_TRUE;

    self.effect.constantColor = GLKVector4Make(
                                               0.0, // Red
                                               0.0, // Green
                                               0.0, // Blue
                                               1.0f);// Alpha

    GLKMatrix4 projectionMatrix = GLKMatrix4MakeOrtho(0, 480, 0, 320, -1024, 1024);
    self.effect.transform.projectionMatrix = projectionMatrix;

}

And here is where I am drawing points/pixels:

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
    GLfloat points[] =
    {
        110.0f, 110.0f,
        111.0f, 110.0f,
        110.0f, 111.0f,
        111.0f, 111.0f,

        112.0f, 112.0f,
        113.0f, 112.0f,
        112.0f, 113.0f,
        113.0f, 113.0f,
    };

    glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    GLKMatrix4 modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, 0.0f);
    self.effect.transform.modelviewMatrix = modelViewMatrix;


    // Prepare the effect for rendering 
    [self.effect prepareToDraw];

    glEnableVertexAttribArray(GLKVertexAttribPosition);
    glVertexAttribPointer(GLKVertexAttribPosition, 2, GL_FLOAT, GL_FALSE, 2*4, points);
    glDrawArrays(GL_POINTS, 0, 8);

}

When I run on simulator it works fine i.e. draw the pixels accordingly, but when I deploy on iPod4 it display some garbage. I am a beginner so need help displaying simple pixels.

  • 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-18T12:20:38+00:00Added an answer on June 18, 2026 at 12:20 pm

    I believe the issue here is that you need to set the built-in gl_PointSize variable in the vertex shader, as the default values are different on the simulator and the device.

    The answer to this question explains further.

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

Sidebar

Related Questions

I need a little help understanding the basics of Jsoup. The following code works
I need a little help consolidating my code. This is the working code but
I need little help with inheritance in C++. I have code with same structure
Need a little help with a SQL / ActiveRecord query. Let's say I have
I need little help on extracting string using csh. I have a variable containing
I am new in Java so I need little help I have String []
I need little help on a homework assignment. I have to create a 10
Need a little help with string formatting... I have a string like this: Bmw
Need a little help again. Say I have an unordered list, and I want
need a little help with extracting part of the URL via regex I have

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.